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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use a different Table or Query in Current Form????

Status
Not open for further replies.

tqd123

MIS
May 11, 2006
8
US
If I create a from using a certain Table or Query for the form's "Record Source". When I am in an Event in that from, how I specify to use a different Table or Query to get some other data???

Thanks,

TD
 
You could put some code using the Dlookup function on the OnCurrent Event of the form like this:

Private Sub Form_Current()
Me![ControlOnForm] = DLookup("[TableFieldName]", "TableName", "[PrimaryKey] = " & Chr(34) & Forms![FormName]![PrimaryKeyOnForm] & Chr(34))
Me![ControlOnForm] = DLookup("[TableFieldName]", "TableName", "[PrimaryKey] = " & Forms![FormName]![PrimaryKeyOnForm]
End Sub

I gave one example for matching a string, the other to match a numeric.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top