Hi,
(Sorry about a previous post with the same Title. There's no content for that post, don't know what happened there...)
I am using Access2000.
Scenario 1 - no problem, works as expected.
Scenario 2 - Need your help here.
Scenario 1: Mainform named [frmPatAuths] (no subforms).
Based on a Table with PK = [auth_id] and many other fields.
On this form I have a custom 'SEARCH_BUTTON' which takes me to another form [frmPatSearch]. On [frmPatSearch] I have a Listbox [lstPatients] which gets it's data from a query.
I have the following code for the [OnDoubleClick] event of [lstPatients]
So the [OnDoubleClick] of the listbox takes me back to my mainform and to the correct record. This all works perfectly well.
Now for my problem. Forget about Scenario1 above. It was just a test. What I need is explained below:
Scenario 2:
All is the same as in Scenario 1 above, with only the following difference:
Main form [frmPatAuths]. Not based on a Table. Just a Form to hold my Subform.
I have a Subform named [frmPatAuthsSub].
Based on a Table with PK = [auth_id] and many other fields.
On this form I have a custom 'SEARCH_BUTTON' which takes me to another form [frmPatSearch]. On [frmPatSearch] I have a Listbox [lstPatients] which gets it's data from a query.
I have the following code for the [OnDoubleClick] event of [lstPatients]
The problem is that the [OnDoubleClick] of the listbox takes me back to my mainform, BUT the cursor is placed at the First Record, instsead of the record I selected from the SearchForm.
I'm almost sure the problem is in my 'reference' to the subform (highlighted in BLUE above), but Access is not giving any errors. It just doesn't move to the correct record.
Any help is appreciated.
Thank you.
Jamie.
(Sorry about a previous post with the same Title. There's no content for that post, don't know what happened there...)
I am using Access2000.
Scenario 1 - no problem, works as expected.
Scenario 2 - Need your help here.
Scenario 1: Mainform named [frmPatAuths] (no subforms).
Based on a Table with PK = [auth_id] and many other fields.
On this form I have a custom 'SEARCH_BUTTON' which takes me to another form [frmPatSearch]. On [frmPatSearch] I have a Listbox [lstPatients] which gets it's data from a query.
I have the following code for the [OnDoubleClick] event of [lstPatients]
Code:
Private Sub lstPatients_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmPatAuths"
Set Recordset = Forms!frmPatAuths.Recordset.Clone
Recordset.FindFirst "[auth_id] = " & Me.lstPatients
Forms!frmPatAuths.Bookmark = Recordset.Bookmark
DoCmd.Close acForm, "frmPatSearch"
Exit_lstPatients_DblClick:
Exit Sub
End Sub
So the [OnDoubleClick] of the listbox takes me back to my mainform and to the correct record. This all works perfectly well.
Now for my problem. Forget about Scenario1 above. It was just a test. What I need is explained below:
Scenario 2:
All is the same as in Scenario 1 above, with only the following difference:
Main form [frmPatAuths]. Not based on a Table. Just a Form to hold my Subform.
I have a Subform named [frmPatAuthsSub].
Based on a Table with PK = [auth_id] and many other fields.
On this form I have a custom 'SEARCH_BUTTON' which takes me to another form [frmPatSearch]. On [frmPatSearch] I have a Listbox [lstPatients] which gets it's data from a query.
I have the following code for the [OnDoubleClick] event of [lstPatients]
Code:
Private Sub lstPatients_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmPatAuths"
Set Recordset = [COLOR="Blue"]Forms!frmPatAuths!frmPatAuthsSub[/COLOR].Recordset.Clone
Recordset.FindFirst "[auth_id] = " & Me.lstPatients
[COLOR="Blue"]Forms!frmPatAuths!frmPatAuthsSub[/COLOR].Bookmark = Recordset.Bookmark
DoCmd.Close acForm, "frmPatSearch"
Exit_lstPatients_DblClick:
Exit Sub
End Sub
The problem is that the [OnDoubleClick] of the listbox takes me back to my mainform, BUT the cursor is placed at the First Record, instsead of the record I selected from the SearchForm.
I'm almost sure the problem is in my 'reference' to the subform (highlighted in BLUE above), but Access is not giving any errors. It just doesn't move to the correct record.
Any help is appreciated.
Thank you.
Jamie.