Tab Control and Dlookup

  • Thread starter disneygoof via AccessMonster.com
  • Start date
D

disneygoof via AccessMonster.com

Greetings All,

I have a form with a tab control on it with multiple tabs (Project,
Contractor, Architect, Engineer). Looking at Contractor, I have a dropdown
that pulls from a contractor list table and returns the name of the
contractor to the screen, but the ContractorID is stored in the table...works
fine. I have added 2 textboxes (unbound) to the contractors tab. Then I
added call procedure the performs two Dlookup's after I update the name in
the contractor dropdown to put the address and city, state, zip. I get NO
error, but I also get no data. I also added the call procedure to the click
procedure on the contractor tab...nothing. I use this same methodoloy in a
differnet form, but NOT on a tab control...what am I doing wrong? I have
debugged to ensure the variables in the call procedure are getting the data
and they are...I just can't seem to get them to display in the TAB control.
If I move the textboxes from the tab control and place them in the main form,
they work fine...

Textboxs on Tab Control are called ContAddress and ContCSZ, both unbound

Call Procedure code

Dim ContAddress As String
Dim cc As String
Dim cs As String
Dim cz As String
Dim ContCSZ As String

ContAddress = Nz(DLookup("ContractorAddress", "tblContractorInfo",
"ContractorID =" & Me.ContractorID), "")
cc = Nz(DLookup("ContractorCity", "tblContractorInfo", "ContractorID =" &
ContractorID), "")
cs = Nz(DLookup("ContractorState", "tblContractorInfo", "ContractorID ="
& ContractorID), "")
cz = Nz(DLookup("ContractorZipcode", "tblContractorInfo", "ContractorID
=" & ContractorID), "")
ContCSZ = cc & ", " & CS & " " & cz
 
D

disneygoof via AccessMonster.com

I feel soooooooo stupid. I was forgetting to put ME. in front of the
variable name...DUH!
 
D

Douglas J. Steele

FWIW, there's actually a much easier way.

Set the RowSource of the combo box to a query that returns all of the
different fields. If, for example, the fields in the RowSource are
ContractID, ContractName, ContractorAddress, ContractorCity, ContractorState
and ContractorZipcode (in that order), you can use

Me.ContAddress = Me.ContractorID.Column(2)
Me.ContCSZ = Me.ContractorID.Column(3) & ", " & _
Me.ContractorID.Column(4) & " " & Me.ContractorID.Column(5)

Note that the Column collection starts numbering at 0, so the content of the
3rd column is referred to as Column(2).
 
D

disneygoof via AccessMonster.com

Nice...I will have to improve my code, thanks much!
FWIW, there's actually a much easier way.

Set the RowSource of the combo box to a query that returns all of the
different fields. If, for example, the fields in the RowSource are
ContractID, ContractName, ContractorAddress, ContractorCity, ContractorState
and ContractorZipcode (in that order), you can use

Me.ContAddress = Me.ContractorID.Column(2)
Me.ContCSZ = Me.ContractorID.Column(3) & ", " & _
Me.ContractorID.Column(4) & " " & Me.ContractorID.Column(5)

Note that the Column collection starts numbering at 0, so the content of the
3rd column is referred to as Column(2).
I feel soooooooo stupid. I was forgetting to put ME. in front of the
variable name...DUH!
[quoted text clipped - 45 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top