Opening a Form to a Specific Record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wish to press a command button and open a second form to a specific record
but I do NOT want to filter the 2nd form, simply move to the record matching
the ID of the first. In pseudocode,

DoCmd.OpenForm "SecondForm"
....Goto Record Where [ID] = Me![ID]

Can anyone help?

Thank you.

Sprinks
 
You will need to provide the value that you want the form to open to in the
record.
I normally assign that value to a local variable.
dim lngRecordID as long
lngRecordID = Me.ControlNameThatHasValue

Then, set the focus to the field on your form that is linked to the record ID.
pseudocode:

me.ID.setfocus

Then use the following to move to the desired record
DoCmd.FindRecord lngRecordID
 
Thanks, Mr. B. That certainly would work.

On the train ride home, I was reading Litwin et al's Access bible, and it
seemed also that OpenArgs could pass the value to the new form, but I think
even better, for my particular application, is to use synchonized subforms.

Since I'm attempting to show further multi-record detail of what I would
like to be a continuous subform (which isn't permitted if one is a subform of
the other), they suggest using parallel subforms which are each linked to a
main form. In the OnCurrent and AfterUpdate events of the first subform, it
writes the linking key to the main form and requeries the second, thereby
synchronizing them. Ingenious.

I expect that I will also need the FindRecord method down-the-road, so I
appreciate your response.

Sprinks

Mr B said:
You will need to provide the value that you want the form to open to in the
record.
I normally assign that value to a local variable.
dim lngRecordID as long
lngRecordID = Me.ControlNameThatHasValue

Then, set the focus to the field on your form that is linked to the record ID.
pseudocode:

me.ID.setfocus

Then use the following to move to the desired record
DoCmd.FindRecord lngRecordID

--
HTH

Mr B


Sprinks said:
I wish to press a command button and open a second form to a specific record
but I do NOT want to filter the 2nd form, simply move to the record matching
the ID of the first. In pseudocode,

DoCmd.OpenForm "SecondForm"
...Goto Record Where [ID] = Me![ID]

Can anyone help?

Thank you.

Sprinks
 
Sounds like you have a completely new approach. Always a good idea to look at
multiple solutions.

Good luck.
--
HTH

Mr B


Sprinks said:
Thanks, Mr. B. That certainly would work.

On the train ride home, I was reading Litwin et al's Access bible, and it
seemed also that OpenArgs could pass the value to the new form, but I think
even better, for my particular application, is to use synchonized subforms.

Since I'm attempting to show further multi-record detail of what I would
like to be a continuous subform (which isn't permitted if one is a subform of
the other), they suggest using parallel subforms which are each linked to a
main form. In the OnCurrent and AfterUpdate events of the first subform, it
writes the linking key to the main form and requeries the second, thereby
synchronizing them. Ingenious.

I expect that I will also need the FindRecord method down-the-road, so I
appreciate your response.

Sprinks

Mr B said:
You will need to provide the value that you want the form to open to in the
record.
I normally assign that value to a local variable.
dim lngRecordID as long
lngRecordID = Me.ControlNameThatHasValue

Then, set the focus to the field on your form that is linked to the record ID.
pseudocode:

me.ID.setfocus

Then use the following to move to the desired record
DoCmd.FindRecord lngRecordID

--
HTH

Mr B


Sprinks said:
I wish to press a command button and open a second form to a specific record
but I do NOT want to filter the 2nd form, simply move to the record matching
the ID of the first. In pseudocode,

DoCmd.OpenForm "SecondForm"
...Goto Record Where [ID] = Me![ID]

Can anyone help?

Thank you.

Sprinks
 
Back
Top