rezlab
rezlab

Reputation: 43

Get Control or Recrdset Value on Continous Form

I have a continuous form with a button for each record and would like to pass the ID of the record passed to another form when a button is clicked. I know how to pass the value. My problem is that regardless of which button is clicked I get the ID of the first record using Forms![Form name]!Text19.Value.

Even in the image below a different record is selected but I get the Id of the first record.

The Id value is in the recordset and also in a hidden field if that helps.

Continuous Form

Upvotes: 0

Views: 623

Answers (1)

Erik A
Erik A

Reputation: 32682

You can use the recordset to retrieve the corresponding data:

Dim r As DAO.Recordset
Set r = Forms![Form name].RecordsetClone 'Clone the recordset
r.Bookmark = Forms![Form name].Bookmark 'Navigate to the active record
MyValue = r!SomeField.Value

Note that if the form is inactive, Bookmark might not refer to the record you think is selected. To avoid this, cache the bookmark (save it on Form_Current)

Upvotes: 3

Related Questions