K
Karen
I'm using a dlookup to an SQL table and when I enter a customer number in my
form the dlookup returns the customers name and address. But not all of the
fields are getting filled in initially. The name, city and zip always fill
in but the address lines and the state don't until i do something to refresh
the screen, like press F7 which does something like spell check. I'm using
Access 2002, most of the tables are in Access except this arcusfil that's a
link to an SQL database that's on the same server but a different drive.
here's the code:
Dim varcustnumber As String
Dim varbillname As Variant
Dim varadd1 As Variant
Dim varadd2 As Variant
Dim varcity As Variant
Dim varstate As Variant
Dim varzip As Variant
Dim varcountry As Variant
Dim varzeros As String
varzeros = "000000000000"
Dim varlen As Integer
varlen = 12 - Len([CUSTNO])
varcustnumber = Mid(varzeros, 1, varlen) & Me![CUSTNO]
varbillname = DLookup("[cus_name]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varadd1 = DLookup("[addr_1]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varadd2 = DLookup("[addr_2]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varcity = DLookup("[city]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varstate = DLookup("[state]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varzip = DLookup("[zip]", "dbo_arcusfil_SQL", "[cus_no] = '" & varcustnumber
& "'")
varcountry = DLookup("[country]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
Me!billname = Left(varbillname, 30)
Me!ADD1 = Left(varadd1, 30)
Me!ADD2 = Left(varadd2, 30)
Me!CITY = Left(varcity, 25)
Me!ST = Left(varstate, 2)
Me!ZIP = varzip
Me!COUNTRY = Left(varcountry, 15)
form the dlookup returns the customers name and address. But not all of the
fields are getting filled in initially. The name, city and zip always fill
in but the address lines and the state don't until i do something to refresh
the screen, like press F7 which does something like spell check. I'm using
Access 2002, most of the tables are in Access except this arcusfil that's a
link to an SQL database that's on the same server but a different drive.
here's the code:
Dim varcustnumber As String
Dim varbillname As Variant
Dim varadd1 As Variant
Dim varadd2 As Variant
Dim varcity As Variant
Dim varstate As Variant
Dim varzip As Variant
Dim varcountry As Variant
Dim varzeros As String
varzeros = "000000000000"
Dim varlen As Integer
varlen = 12 - Len([CUSTNO])
varcustnumber = Mid(varzeros, 1, varlen) & Me![CUSTNO]
varbillname = DLookup("[cus_name]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varadd1 = DLookup("[addr_1]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varadd2 = DLookup("[addr_2]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varcity = DLookup("[city]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varstate = DLookup("[state]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
varzip = DLookup("[zip]", "dbo_arcusfil_SQL", "[cus_no] = '" & varcustnumber
& "'")
varcountry = DLookup("[country]", "dbo_arcusfil_SQL", "[cus_no] = '" &
varcustnumber & "'")
Me!billname = Left(varbillname, 30)
Me!ADD1 = Left(varadd1, 30)
Me!ADD2 = Left(varadd2, 30)
Me!CITY = Left(varcity, 25)
Me!ST = Left(varstate, 2)
Me!ZIP = varzip
Me!COUNTRY = Left(varcountry, 15)