Variable name in DLookup (1 Viewer)

echorley

Registered User.
Local time
Today, 04:17
Joined
Mar 11, 2003
Messages
131
Can I use a variable for the expression in a DLookup function?

For example, I would like to use the value from a textbox to determine which field is used:

myStart = Me.CurrentStartPoint

Mileage = DLookup("['myStart']", "MileageChart", "[Finish] =" _
& Forms![frmDailyMileage]!myFinishPoint)
 

wazz

Super Moderator
Local time
Today, 16:17
Joined
Jun 29, 2004
Messages
1,711
i think for this there could be a few "issues". but to try do the job, try to get the value you need from a query first to see if it's possible.

put your mileagechart table in the query grid, add the CurrentStartPoint field and Finish field, add the criteria (Forms![frmDailyMileage]!myFinishPoint), open your form and test the query. do you get only one row in the result? if you can somehow get the result you need from your query, use the query as your lookup source.

Mileage = DLookup("CurrentStartPoint", "qryGetStart")
 

Users who are viewing this thread

Top Bottom