Hi guys,
I'm trying to set the record source for my main form and search within a subform, from a command button on the main form, to find a record but I am getting a type mismatch error with this code:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim frm1 As Form
Set frm1 = Forms!FormMain.Form
frm1.RecordSource = "SELECT QueryRecSource.[Pay Number], * " & _
"FROM QueryRecSource " & _
"WHERE QueryRecSource.[Pay Number]= '" & [Forms]![FormMain].Form![FormSubMainLookUp]![PayNo] & "'"
Dim frm2 As Form
Set frm2 = Forms!FormMain.Form!FormSubMainRecords
Dim rs As Object
Set rs = frm2.Recordset.Clone
rs.FindFirst "[RecId] =" & [Forms]![FormMain].Form![FormSubMainLookUp]![RecId]
If Not rs.EOF Then frm2.Bookmark = rs.Bookmark
Can anyone see where I am going wrong?
Thanks in advance.
I'm trying to set the record source for my main form and search within a subform, from a command button on the main form, to find a record but I am getting a type mismatch error with this code:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim frm1 As Form
Set frm1 = Forms!FormMain.Form
frm1.RecordSource = "SELECT QueryRecSource.[Pay Number], * " & _
"FROM QueryRecSource " & _
"WHERE QueryRecSource.[Pay Number]= '" & [Forms]![FormMain].Form![FormSubMainLookUp]![PayNo] & "'"
Dim frm2 As Form
Set frm2 = Forms!FormMain.Form!FormSubMainRecords
Dim rs As Object
Set rs = frm2.Recordset.Clone
rs.FindFirst "[RecId] =" & [Forms]![FormMain].Form![FormSubMainLookUp]![RecId]
If Not rs.EOF Then frm2.Bookmark = rs.Bookmark
Can anyone see where I am going wrong?
Thanks in advance.