dlookup
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Dlookup

resolvedResolved · High Priority · Version 2003

replyReply Fri 26 Sep 2008, 09:59Delegate Paul said...

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

For upcoming training course dates see: Pricing & availability

replyReply Fri 26 Sep 2008, 11:24Trainer Laura said...

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

replyReply Fri 26 Sep 2008, 22:06Delegate Paul said...

RE: Dlookup

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

 

Please browse our web site to find out more about
access+courses+in+london and other Microsoft training courses.

Access tip:

How To Find All Overdue Accounts?

To find overdue accounts create a filter that compares today's date with the Invoice Date in the table. To do this:

1. Open the Query in Design View
2. Select the field for the filter and in the criteria row enter:

<Date()

This filter returns records where the Invoice Date is before today's date.

This filter can be manipulated if, for instance, Invoices are due 15 days after the Invoice Date. For this the filter would be:

<Date()-15

This filter returns records where the Invoice Date is 15 days before today's date.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard