Textbox Value Find Primary key

aron.ridgway

Registered User.
Local time
Today, 16:25
Joined
Apr 1, 2014
Messages
148
Hi There

I have an unbound textbox in a form which is filled with a text value eg "RWL" when the form opens. I now need another textbox that goes to the Company Data base finds the "RWL" text and finds its Primary key and puts it in the new textbox?

whats the best way to do this?
 
DLOOKUP is probably best, or you can code it on the text box change event, but you'll also need to put it in the form load for that.
 
?? Just curious, why do you need the PK in a text box??
 
I though Dlookup might be the one, can you use it in a textbox property or will i have to use vba?

I need the PK as i keep getting the message you cannot add or change a record because a related record is required in table 'tblCompany'
 
I need the PK as i keep getting the message you cannot add or change a record because a related record is required in table 'tblCompany'

To me this message is saying to you:

You have tables in a 1 to Many relationships. You are attempting to add a record to the Many side, but there is no matching record in the 1 table.

An example: Consider 2 tables.
tblParent and tblChild in a 1 to Many relationship.

You are trying to add a Child, but there is no Parent record.
 

Users who are viewing this thread

Back
Top Bottom