auto fill in field

DAPPLE

Registered User.
Local time
Today, 23:02
Joined
Apr 11, 2002
Messages
73
I have a form created from a table which was created from a query in access... hope I'm getting the terminology right. Any the db is related to payroll. Is there any way I can fill in a field with a payroll code of B5Z, which will automatically fill in the relating fields such as: Payroll Coord for that code, payroll frequency for that code, and payroll location for that code? This would save so much time because I manually key in those fields with each new enrollment. I need those other fields to be displayed. Can anyone offer some help?!
Hope yall are having a hap-hap-happy New Year!
 
Use the DLookup function.

Provided you are storing this information in a table somewhere then you can automatically call the information rather than manually input it.

PHP:
txtPayrollLocation = DLookup("[Location]","tblPayrollInfo","[PayrollCode] = '" & txtPayrollCode & "'")
 
Thanks, I'll print your response, try to digest it... and see if I can put it to work. Anything to make my job easier - I love.

Thanks again!
 
Oh, one more thing... where exactly am I suppose to enter this formula? on the properties tab somewhere I assume.. overlook the ignorance.

In the control source, with expression builder?
once again, I appreciate any help.
 
Last edited:
You can use the DLookup function (like in Mile-O-Phile's post) and put it in the AfterUpdate event of the field where you select the Payroll Code. That is assuming that you want to populate these other fields with information generated from that payroll code.

Use 1 DLookup function for each field that you need to populate. What this does is lookup the payroll code entered in the appropriate table and retrieve the other field related to that code.

Example: Table: tblWhat has 3 fields: ID, Name and Color.

You have a form where you select/fill in an id and want it to populate the NAme and Color based on the ID. You place this code in the ID field's AfterUpdate event on the form:

DLookup ("Name","tblWhat","[ID]=[forms]![frmYourForm].[ID]")
DLookup ("Color","tblWhat","[ID]=[forms]![frmYourForm].[ID]")

This looks up the Name and Color fields in the tblWhat where the ID is equal to the ID selected/filled in on your form.

HTH
 

Users who are viewing this thread

Back
Top Bottom