Karl001
asked on
Return on a specific record - Access Form
Hi,
On a main form, I have a list of records, with a details button on each row.
When I click on the details button, a new form is opened with details of the selected record
When I close the details form, I would like to go back on the record previously selected.
Currently, I return on the top of the records list in the main form.
On a main form, I have a list of records, with a details button on each row.
When I click on the details button, a new form is opened with details of the selected record
When I close the details form, I would like to go back on the record previously selected.
Currently, I return on the top of the records list in the main form.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To be sure
Dim varId is a module variable
Code:
varId = me.recordId
is in click event (detail button)
Code:
me.recordsetclone.findfirs t "[recordID]= " & varID
if not me.recordsetclone.nomatch then
me.bookmark=me.recordsetcl one.bookma rk
end if
is in Form_Current event
Dim varId is a module variable
Code:
varId = me.recordId
is in click event (detail button)
Code:
me.recordsetclone.findfirs
if not me.recordsetclone.nomatch then
me.bookmark=me.recordsetcl
end if
is in Form_Current event
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution used:
In details Form, on click event (closing button)
Private Sub btnClose_Click()
Dim strActiveRecord As String
strActiveRecord = "[trainingNo]= '" & Me.txtTrainingNo & _
" ' AND [departmentId]=" & Me.lstDepartment
DoCmd.Close
Forms. mainForm.Requery
Forms. mainForm.Recordset.FindFir st strActiveRecord
End sub
In details Form, on click event (closing button)
Private Sub btnClose_Click()
Dim strActiveRecord As String
strActiveRecord = "[trainingNo]= '" & Me.txtTrainingNo & _
" ' AND [departmentId]=" & Me.lstDepartment
DoCmd.Close
Forms. mainForm.Requery
Forms. mainForm.Recordset.FindFir
End sub
? :-(
'save the recordid in a variable
dim varID
varID = me.recordId
me.requery
'after the requery, find the record using
me.recordsetclone.findfirs
if not me.recordsetclone.nomatch then
me.bookmark=me.recordsetcl
end if