Milothicus
Registered User.
- Local time
- Today, 16:49
- Joined
- Sep 24, 2004
- Messages
- 134
I'm using this code to bring up a selected record from search results:
Private Sub listbox_Click()
On Error GoTo Err_listbox_Click
Dim stDocName As String
Dim rst As Recordset, strCriteria As String
stDocName = "editform"
strCriteria = "[field]=" & "'" & Me![listbox] & "'"
DoCmd.OpenForm stDocName
Set rst = Forms!editform.RecordsetClone
rst.FindFirst strCriteria
Forms!editform.Bookmark = rst.Bookmark
Me!listbox = ""
Exit_listbox_Click:
Exit Sub
Err_listbox_Click:
MsgBox Err.Description
Resume Exit_listbox_Click
End Sub
**Note**
*Substitute listbox for the name of your listbox
*Substitute editform for the name of the form that will contain the particular case you wish to view and edit
*Substitute field for the name of the field which you have done your search by. i.e. lastname
I got it from here.
It works fine, but only if you're opening a new form. my search form is on a tab. I'd like it to go to another tab that's already open and go to the selected record. I think i'm close to having it working, but i'm not sure what to put in the green quotes. the name of the main form is Enquiry, the name of the subform is Input, i'm not sure what the tab control name is, but i can get that if necessary. how do i name the subform in this case?
Private Sub listbox_Click()
On Error GoTo Err_listbox_Click
Dim stDocName As String
Dim rst As Recordset, strCriteria As String
stDocName = "editform"
strCriteria = "[field]=" & "'" & Me![listbox] & "'"
DoCmd.OpenForm stDocName
Set rst = Forms!editform.RecordsetClone
rst.FindFirst strCriteria
Forms!editform.Bookmark = rst.Bookmark
Me!listbox = ""
Exit_listbox_Click:
Exit Sub
Err_listbox_Click:
MsgBox Err.Description
Resume Exit_listbox_Click
End Sub
**Note**
*Substitute listbox for the name of your listbox
*Substitute editform for the name of the form that will contain the particular case you wish to view and edit
*Substitute field for the name of the field which you have done your search by. i.e. lastname
I got it from here.
It works fine, but only if you're opening a new form. my search form is on a tab. I'd like it to go to another tab that's already open and go to the selected record. I think i'm close to having it working, but i'm not sure what to put in the green quotes. the name of the main form is Enquiry, the name of the subform is Input, i'm not sure what the tab control name is, but i can get that if necessary. how do i name the subform in this case?