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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup fails when Form is opened from Macro

Status
Not open for further replies.

S2art7

IS-IT--Management
Apr 25, 2011
4
0
0
US
I am confused.
I want to use Dlookup fill the "STCity" and "STState" fields on my "Quotes" form with the appropriate data from a query "ShipToName" based on the selection in a combo box named "cboCustomer". Here are the functions.
<code>=DLookUp("STCity","ShipToName","STName=cboCustomer")
=DLookUp("STState","ShipToName","STName=cboCustomer")</code>
These functions work perfectly when I open the form object directly.
However in actual use the "Quotes" form is opened via a macro "Prep" behind a button on another form called "Equipment". This macro Opens the "Quotes" form and sets the values of several fields on that form based on the entries previously made on the "Equipment" form. The macro does not reference the "STCity" or "STState" fields. When "Quotes" is opened via the macro the Dlookup functions simply do not run.
What am I missing?
 
S2art7,
Is that your actual code? I can't see how it would work with "cboCustomer" inside the quotes and no reference to a form.

Is the Row Source of cboCustomer the ShipToName query? If so, you could make sure the two columns are included in the Row Source and use:

Code:
Me.txtCity = Me.cboCustomer.Column(x)
Code:
Me.txtState = Me.cboCustomer.Column(y)

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top