Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

dlookup

ResolvedVersion 2003

Paul has attended:
Access VBA course

Dlookup

I've done lots of dlookups before but don't understand why this one isn't working.

I have a table called tblMonths which contains the fields MonthAndYear (content e.g. "September 2008" in text) and PriorMonth (number - single format, contents e.g. 200809)

This table is used successfully to populate cmbTeam on form frmTeamKPIs.

The dlookup reads:

=DLookUp("[PriorMonth]","[tblMonths]","[MonthAndYear] = " & """ & forms.frmTeamKPIs.cmbMonth & """)

I get a blank field when trying to run.

Can you help??

Thanks
Paul

RE: Dlookup

Hi Paul

I hope I undersatand your question correctly and that the field MonthAndYear contains text in the same format as cmbMonth on the form.

Building a criteria to look in a text field I would usually use a single quote, ie

=DLookUp("[PriorMonth]","[tblMonths]","[MonthAndYear] = '" & forms.frmTeamKPIs.cmbMonth & "'")

If that doesn't work try doing a debug.print of the criteria to make sure it looks okay.

Let me know how you get on.

Laura

RE: Dlookup

Thanks very much Laura, I thought it would be something simple...and it was.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Combo box for finding records

You can use a combo box in a form to look up a record. If you place the comb box in the Form header, by then selcting they a field type from the drop down loist, you will see the record for it

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.12 secs.