dlookup

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

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Dlookup

Dlookup

resolvedResolved · High Priority · Version 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:

Remove spaces in a table

If you have a table that has too many space marks littered around, you can create a update query and use the trim function to get rid of any excess space marks

View all Access hints and tips


Server loaded in 0.07 secs.