Determining curently selected record...

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

I have a form that lists records from a table. I want the user to highlite
the appropriate record (by clicking on the record selection area to the
left of the record) and then click an "Edit Selected Record' button I placed
on the form.

How do I know which record was the one that was selected by the user so that
I can edit the appropriate record on the next form?

Thanks,

Brad
 
Brad said:
I have a form that lists records from a table. I want the user to highlite
the appropriate record (by clicking on the record selection area to the
left of the record) and then click an "Edit Selected Record' button I placed
on the form.

How do I know which record was the one that was selected by the user so that
I can edit the appropriate record on the next form?


The answer to this question is going to sound kind of dumb,
because the currently selected record is known as the
Current Record. Duh ;-)

What that means is that you can refer to any of the fields
in the form's record source table/query in the usual way and
get its value from the current record (actually you can not
get a value from any other record without going way out of
your way).

To open another form to the same record, set the second form
to the same record source and modify the wizard generated
Click event procedure for the button so it looks something
like this:

stDoc = "formname"
stWhere = "primarykeyfield = " & Me.primarykeyfield
DoCmd.OpenForm stDoc, , , stWhere
 
Perfect... Thanks for that!
Marshall Barton said:
The answer to this question is going to sound kind of dumb,
because the currently selected record is known as the
Current Record. Duh ;-)

What that means is that you can refer to any of the fields
in the form's record source table/query in the usual way and
get its value from the current record (actually you can not
get a value from any other record without going way out of
your way).

To open another form to the same record, set the second form
to the same record source and modify the wizard generated
Click event procedure for the button so it looks something
like this:

stDoc = "formname"
stWhere = "primarykeyfield = " & Me.primarykeyfield
DoCmd.OpenForm stDoc, , , stWhere
 
Back
Top