I found this thread: thread702-1083535 , but I don't seem to be getting this right.
I have a main form and it has Deals. This main form has a tab control for information pertaining to a deal. One of those pages has a sub-form for singers.
Once you enter a singer, you can enter in a work history for that singer. To do this, I have a combo box on the Singer subform, which opens the work history form. It is supposed to tie to the current singer from the singer subform on the deals main form.
When I click the command button to open the sub form, it is not filtering correctly. I looked at the code in the above referenced thread and tried to adjust my code to use the recordset clone. I had originally put a command button on the form and used the wizard to say show specific records and then the code populated to do the stlinkcriteria.
So my isssue is 2 fold because I need it to filter to just that singer's work history. The part 2 is if they don't have work history yet, I need it to open to a new record so one can be started.
This is what I have. When I run it, I get an "Object variable or with block variable not set". I am not sure how to fix it:
I appreciate any help to get this working. Thanks!
misscrf
It is never too late to become what you could have been ~ George Eliot
I have a main form and it has Deals. This main form has a tab control for information pertaining to a deal. One of those pages has a sub-form for singers.
Once you enter a singer, you can enter in a work history for that singer. To do this, I have a combo box on the Singer subform, which opens the work history form. It is supposed to tie to the current singer from the singer subform on the deals main form.
When I click the command button to open the sub form, it is not filtering correctly. I looked at the code in the above referenced thread and tried to adjust my code to use the recordset clone. I had originally put a command button on the form and used the wizard to say show specific records and then the code populated to do the stlinkcriteria.
So my isssue is 2 fold because I need it to filter to just that singer's work history. The part 2 is if they don't have work history yet, I need it to open to a new record so one can be started.
This is what I have. When I run it, I get an "Object variable or with block variable not set". I am not sure how to fix it:
Code:
Private Sub cmdOpenWorkHistory_Click()
On Error GoTo Err_cmdOpenWorkHistory_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWorkHistory"
stLinkCriteria = "[FKSinger]=" & Me![PKSingerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim rst As DAO.Recordset, frm As Form, sfrm As Form
Set sfrm = Forms!frmWorkHistory
Set rst = sfrm.RecordsetClone
rst.FindFirst "[FKSinger]=" & Me![PKSingerID]
If rst.NoMatch Then
MsgBox "Singer work history not found!"
Else
frm.Bookmark = rst.Bookmark
'
' Set rst = sfrm.RecordsetClone
' rst.FindFirst "[fkSinger]=" & Me![PKSingerID]
'
' If rst.NoMatch Then
' MsgBox "Singer work history not found 2!"
' Else
' sfrm.Bookmark = rst.Bookmark
' End If
End If
Set rst = Nothing
Set sfrm = Nothing
Exit_cmdOpenWorkHistory_Click:
Exit Sub
Err_cmdOpenWorkHistory_Click:
MsgBox Err.Description
Resume Exit_cmdOpenWorkHistory_Click
End Sub
I appreciate any help to get this working. Thanks!
misscrf
It is never too late to become what you could have been ~ George Eliot