Maintain current record id through default tabs and new form opening

soulice

Registered User.
Local time
Today, 00:12
Joined
Dec 21, 2011
Messages
41
I have a db with 4 forms. My users want to be able to open a form, go to record x then open another form and have it open to the same record x.

Also, the standard tabs that you get when opeing multiple forms, when you are on form y and change to another form via the tabs, do the same thing...if form y is on record x and you tab to form 2 it should move to record x.

I am thinking global var to get and set the id, just not sure if this is the right way to approach this.
 
A global variable should work. I avoid them though, because sometimes they get reset, I believe it is when there is an unhandled error. If you go this route, be sure to test if there is anything there:
Code:
if len(nz(YourGlobal))=0 then YourGlobal=Some default value
If you don't do that, it wont hurt anything. Alternatively, you can open forms and use the OpenArgs method to pass data to the form. Although this wont help you if you are simply swithcing tabs.

As far as the tabs go, see if the OnCurrent event fires when you switch tabs (I don't use them!). Place this in the OnCurrent
Code:
Msgbox "oncurrent"
If that works, then in the on current you can move to your global variable.

Or...I think forms have an OnGotFocus event, you could try that one too if current doesn't work.
 
You da man! Ran some test, ended up using Form_Activate and Form_Deactivate to get and set the current record id. Activate gets fired during the open process as well as the tab select. Deactivate gets fired on close or lost active tab status.
 
Glad I could help. Remember that message box trick, it's great for debugging.
 

Users who are viewing this thread

Back
Top Bottom