Reputation: 185
I'm trying to use a DLookup in Access VBA, but even with a criteria (hard-coded or from a text box), the lookup only returns the value from the first record in the table, not a record that matches the criteria.
Here is my code;
JOBID = DLookup("[ID]", "[MASTER PLANNER]", "[JOB NUMBER] = '" & Me.JOB_NUMBER & "'")
ID is a numerical ID field, [JOB NUMBER] is a string (like this; S019191-1) and JOB_NUMBER is the field on the form.
Anyone have any ideas on this at all?
Thanks!
Upvotes: 0
Views: 2004
Reputation: 732
Dlookup function return value. Not record. If you want to return all the record/s you can do it with : 1. Query - do display the results in form/report. 2. Recordset - to use it in vba code. Here is an explain how to use recordsets: How to use recordsets for beginners
Upvotes: 1