Getting a value from a query

Andrew Thorpe

Registered User.
Local time
Today, 23:23
Joined
Apr 18, 2009
Messages
59
In writing a simple expression to calculate pay, I have in VB written ShiftPay = WeekdayRate ......where the WeekdayRate is stored in a module as a constant.
If I had 2 or more shops, I would have more lines in the module and would have more blocks of code.
I would prefer to have the WeekdayRate as an attribute of the Shop such that a query to find the value would have just two fields: ShopID and the WeekdayRate
I’ve never – in VB code – taken a value from a query. I guess it must read something like
ShiftPay = WeekdayRate from qryShopWeekrate where ShopID = frmShop!ShopID.
Could anyone give me an example - or perhaps a link to the best Help section. Thank you. Andrew
 
Last edited:
Try DLookup(). Code would look something like ...
Code:
Debug.Print DLookup("WeekdayRate", "tShop", "ShopID = 12")
Syntax ...
Code:
DLookup(field, table, criteria)
 
That's done it. Many thanks. Andrew
 

Users who are viewing this thread

Back
Top Bottom