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

Need Primary Key updated on subforms...

Status
Not open for further replies.

theog

Programmer
May 1, 2001
13
US
Hi All,

I've got a tab control with forms on each tab. The first tab holds my (autonumber) primary key field, which I need carried over to the other forms on the other tabs to serve as foreign keys in their respective tables.

So, I create a new record, which populates my PK field on tab 1, but then nothing I've tried will get that dang number into the FK fields on my other forms on the other tabs...

Any helpful tips/techniques out there? Am I just going about this wrong? Should I go to truck-driving schoool?

TIA
 
Dim a variable in the General section of the form and store the PK value in this variable when it is generated. Then use it with the GotFocus event, combined with some validation checks... Don't forget to set it to 0 or "" when it's not needed anymore, otherwise navigaing through tabs will give you headahches.

Another way would be to have a textbox on the form (outside the tab control) populated with the PK when it's generated, then use it in the other tabs. This may be better for what you need.

And...driving trucks is fun (I've tried it a few times), but not that fun [smile]
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Danvlas, you are right... thanks!

Here's what I did. Put an unbound, hidden text box on the main form, and when my PK was generated on the first tabbed form, I had the aformentioned main form PK textbox populated with the value.

I then used the tab change event with a select case statement to figure out which tab the user moved to, then populate that tab's form's hiddend FK texbox value with the main form's hidden PK textbox value. Works good, lasts long time... Still thinkin' about truck-drivin' tho'...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top