Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab vontrol not functioning properly

Status
Not open for further replies.

mytaurus2000

Technical User
Oct 4, 2006
138
US
I have a tabcontrol with 2 pages, BillTo and ShipTo

On each page there is a CheckAddress Button that looks at the address and assigns 4 digit post code and county.

Problem is when I click the button nothing happens, but if I go to other page and back, then it works. What is going on?
 
Post back the code behind the form and let's have a go....

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
Here is the code, I even changed to check for the value but it is doing the same:

Private Sub cmdCheckAddress_Click()
' ** NOTE Variable Names Are being duplicated from documentation.
Dim hUnz As Long
Dim szFirmName As String * 51 ' ** All Fixed Sized Are To 51 Default
Dim szPRUrb As String * 51
Dim szDelLine As String * 51
Dim szLastLine As String * 51
Dim szCity As String * 51
Dim szState As String * 51
Dim szZIP As String * 51
Dim szCOUNTY As String * 51
Dim szAREACODE As String * 51
Dim Result As Long
Dim Line1 As String, line2 As String, line3 As String, Line4 As String

' First open the DLL. Bail out if this fails...

hUnz = UNZ_INIT_EX()
If hUnz = 0 Then 'OOps...someting is wrong...
MsgBox "DLL initialization failed"
Forms!frmApplicantDataEntry![SSN].SetFocus
Exit Sub
End If

' MsgBox "DLL Init okay"

' If we get here, the DLL is open and ready to check an address
' Next, prepare the 4 address parameters for UNZ_CHECKADDRESS()

If Address.Value = 0 Then
Line1 = "" ' no firm name
line2 = "" ' no Puerto Rico addresses in the demo
line3 = StreetAddress ' this is the street address
Line4 = City & ", " & State & " " & Zip ' build city-st-zip
Else
Line1 = "" ' no firm name
line2 = "" ' no Puerto Rico addresses in the demo
line3 = ShipAddress ' this is the street address
Line4 = ShipCity & ", " & ShipState & " " & ShipZipCode ' build city-st-zip
End If

' Call the DLL to check the address and get the result code
Result = UNZ_CHECKADDRESS(hUnz, Line1, line2, line3, Line4)

' MsgBox "Check Address result = " & Result

' Examine the result code to determine what happened
Select Case Result

Case XC_GOODADDR ' The address was just fine the way it was...
' MsgBox "Address found - no changes necessary"

Case XC_ZIP To XC_5DIG ' The address was corrected
' MsgBox "Address found and corrected"

' Here we get the corrected address strings from the DLL

' First we get the original strings, corrected as necessary

If Address.Value = 0 Then
Result = UNZ_GETSTDADDRESS(hUnz, szFirmName, szPRUrb, szDelLine, szLastLine)
StreetAddress = FixedToVar(szDelLine)
Else
Result = UNZ_GETSTDADDRESS(hUnz, szFirmName, szPRUrb, szDelLine, szLastLine)
ShipAddress = FixedToVar(szDelLine)
End If

' City-ST-ZIP are already in szLastLine, but we need them as separate strings
If Address.Value = 0 Then
Result = UNZ_GETCITY(hUnz, szCity)
City = FixedToVar(szCity)

Result = UNZ_GETSTATE(hUnz, szState)
State = FixedToVar(szState)

Result = UNZ_GETZIP(hUnz, szZIP)
Zip = FixedToVar(szZIP)
Else
Result = UNZ_GETCITY(hUnz, szCity)
ShipCity = FixedToVar(szCity)

Result = UNZ_GETSTATE(hUnz, szState)
ShipState = FixedToVar(szState)

Result = UNZ_GETZIP(hUnz, szZIP)
ShipZipCode = FixedToVar(szZIP)
End If
'County

If Address.Value = 0 Then
Result = UNZ_CHECKADDRESS(hUnz, szFirmName, szPRUrb, szDelLine, szLastLine)
County = FixedToVar(szDelLine)

Result = UNZ_GETCOUNTY(hUnz, szCOUNTY)
County = FixedToVar(szCOUNTY)
Else
Result = UNZ_CHECKADDRESS(hUnz, szFirmName, szPRUrb, szDelLine, szLastLine)
ShipCounty = FixedToVar(szDelLine)

Result = UNZ_GETCOUNTY(hUnz, szCOUNTY)
ShipCounty = FixedToVar(szCOUNTY)
End If

Case XC_MULT ' Multiple matching addresses were found
MsgBox "Multiple matching addresses found"

Case XC_BADADDR To XC_FHERR ' The address (or city-st-ZIP) is invalid
MsgBox "Address was not found"

Case Else
MsgBox "An internal error occurred during the address check"

End Select

' Close the DLL, ignore the result
Result = UNZ_TERM(hUnz)

' Move focus back to first field...
Forms!frmApplicantDataEntry![Home Phone].SetFocus

End Sub
 
How are ya mytaurus2000 . . .

Whats the name of the [blue]?.dll[/blue] file?

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top