If form is open, close; Else, open it.

  • Thread starter Thread starter Bradley C. Hammerstrom
  • Start date Start date
B

Bradley C. Hammerstrom

Access2000

Scenario: Two forms the user will go back and forth between; browsing
records on one form and clicking a button to go to the same record on the
other form. Then, browse on that form; find a record; click button to go the
same record back on first form. And so on. . .

I have working code for both command buttons (using OpenArgs), and for both
forms (OnLoad FindFirst), but this only works if the form is Opened (i.e.
closed first). So I think I need a line in the command button code that
evaluates the state of the calling form (is it opened or closed?), and opens
it if it is closed--or closes, then opens it if it is opened--so that the
OnLoad event happens.

Maybe I'm on the wrong track and should try OnFocus or similar?

Brad H.
 
Why not simply use your CommandButton to set the same Record as the
CurrentRecord in the "Other" Form, make the "Other" Form Visible and then
hide the current Form. You database will run much faster as it doesn't have
to close / open Form and re-populate the RecordSource.

You will need to work out the suitable Record-locking so that you don't have
Record-locking problems.
 
That's a bit more complicated since even though the Subform on Form2 has the
same Query as in Form1, the Recordset may be different due to the filtering
by the LinkMasterFields / LinkChildFields.

Need a bit more info. on:

1. Whether Form1 / its Subform are linked? If they are a bit more detail
of the RecordSources and their relationship, especially the main Form1.

2. Which View are you using for the Subform? ( FormView?
ContinuousFormView? DatasheetView of the Form?)

3. Is PhotoID uniquely indexed?
 
Back
Top