Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a field from another table onto a form

Status
Not open for further replies.

Airbiskit

Technical User
Joined
May 20, 2003
Messages
89
Location
GB
What I want to do is get a value from a another table onto a form.

The current form is from a table that consists of name, security no., start date, department, location etc and I want to get from another table, that is linked using the security no, the value from a field called grade.

I am no expert and I tried just creating an unbound field and pointing it to the grade field on the other table but this was wishful thinking. What I want to do is if you enter in a security no into the form the grade field automatically gets filled in by looking into the other table. This would be ideal.

The form will be used to enter information into so will the best way to get the grade field value be a subquery or subform.

Any help would be great

Thx



 
Hi,

You just need to create a query to base the RecordSource of your form on, instead of selecting the name of a table. On the property sheet, on the Data tab click the build button after 'RecordSource' field (...).

Then just create the query including both tables you want to get the info from. The field from the other table should be included in the field list of your form.

That should be enough to get you started, but if I've understood your post of if you need more help. Let me know.

Dean :-)
 
You can also use the DLookup command in the code on the OnChange or AfterUpdate event of 'security no.', it would look something like this:

Code:
Private Sub txtSecNo_Change()

    txtGrade = DLookup("tblSecurityTable", "Grade", "SecID = " & txtSecNo)

End Sub

Ahdkaw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top