Copy PK to Foreign Key on a Form

faceman

Registered User.
Local time
Today, 19:36
Joined
Feb 11, 2003
Messages
20
I have 4 tables created. In the main table, the PK is named Fileno. This is an text field with a length of 10. This same field is also the foreign key in my other 3 tables. I have all the information brought together in a query and have a form created based on the query. Now what I want to do is after update (for changes or new record) of the PK, is to copy that same information into the other 3 fields and update each of the tables with it. I know this can be done, but for the life of me, I can't figure it out. I'm probably going to kick myself after I see how it's done.


Thanks once again guys,

Faceman
 
Updatable PK

Pat, I totally agree with you on the updatable Primary field being a bad idea, but in this case it is simply unavoidable. I have the tables' relations set up like that already. I problem was, I did not want to have to type the "fileno" into the 4 seperate fields. I would prefer to have 3 of them invisible and would autofill off the one I input into. This code seemed to work on a simple database I just made. I put this on the After_Update on the visible fileno field:

If Not IsNull(Me.ID1) Then

Me.ID2.Value = Me.ID1.Value
Me.ID3.Value = Me.ID1.Value

End If

Is this the best way to do it or would you suggest something else?


Faceman
 

Users who are viewing this thread

Back
Top Bottom