Look up

Ty Gooden

New member
Local time
Today, 12:07
Joined
Jul 31, 2009
Messages
4
I've got a bound control on a form that is showing the value in the AccountID field of the person who has crreated a particular record. I want this to show the persons name which is stored in a different table (linked by AccountID).

This field doesn't need to be editable as it is for lookup purposes only. I would set the record source for the form to a query rather than directly to a table but there's other fields on the form that will be used for data entry.

I could also put this field as a subform but I'm sure there must be an easier solution!
 
I think its better to base your form on a query rather than the table, you would then stand a chance of linking the two tables together to display the data you want.
 
Since this is for "lookup" purposes only, why not use Lookup()?

'If AccountID isNumeric

Code:
Private SubAccountID_BeforeUpdate(Cancel As Integer)
 Me.NameField = DLookup("AccountID", "TableOrQueryName", "AccountID = " & Me.AccountID) + 1
End Sub
'If AccountID is Text
Code:
Private SubAccountID_BeforeUpdate(Cancel As Integer)
 Me.NameField = DLookup("AccountID", "TableOrQueryName", "[AccountID] = '" & Me.AccountID & "'") + 1
End Sub
 

Users who are viewing this thread

Back
Top Bottom