Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?

Dlookup fails when Form is opened from Macro

S2art7 (IS/IT--Management)
11 May 12 10:03

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.
=DLookUp("STCity","ShipToName","STName=cboCustomer")
=DLookUp("STState","ShipToName","STName=cboCustomer")

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?

dhookom (Programmer)
11 May 12 16:22
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 --> vba

Me.txtCity = Me.cboCustomer.Column(x)

CODE --> vba

Me.txtState = Me.cboCustomer.Column(y)

Duane
Hook'D on Access
MS Access MVP

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close