I have a form called frm_Mainform that is used to enter general information regarding the service of an instrument.
frm_MainForm
MainFormID <PK>
PersonPerformingService <Text>
Department <text>
ServiceDate <Date>
I now have a subform that contains:
sfrm_Instrument
InstrumentID <PK>
MainFormID <FK>
Instrument Name <text>
sfrm_Instrument is embedded in frm_MainForm
I have a search form with the following code behind a command button:
Dim stDocName As String, Whereclause As String, frm As Form, sfrm As Form
stDocName = "review_frm_mainform"
If Not IsNull(Me.cbo_Department) Then
Whereclause = "[Department] = '" & Me.cbo_Department & "'"
End If
If Not IsNull(Me.cbo_Person) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "PersonPerformingService = '" & Me.cbo_Person & "'"
End If
If Not IsNull(Me.cbo_Instrument) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Instrument] = '" & Me.cbo_Instrument & "'"
End If
DoCmd.OpenForm stDocName
DoCmd.Maximize
DoEvents 'Allow time for the form to open
Set frm = Forms!Review_frm_MainForm
Set sfrm = frm!frm_Instrument
sfrm.Filter = Whereclause
sfrm.FilterOn = True
Set sfrm = Nothing
Set frm = Nothing
When I run this code, I get a "Type Mismatch" error. Can anyone tell me where this error is coming from?
Thanks
Rene
frm_MainForm
MainFormID <PK>
PersonPerformingService <Text>
Department <text>
ServiceDate <Date>
I now have a subform that contains:
sfrm_Instrument
InstrumentID <PK>
MainFormID <FK>
Instrument Name <text>
sfrm_Instrument is embedded in frm_MainForm
I have a search form with the following code behind a command button:
Dim stDocName As String, Whereclause As String, frm As Form, sfrm As Form
stDocName = "review_frm_mainform"
If Not IsNull(Me.cbo_Department) Then
Whereclause = "[Department] = '" & Me.cbo_Department & "'"
End If
If Not IsNull(Me.cbo_Person) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "PersonPerformingService = '" & Me.cbo_Person & "'"
End If
If Not IsNull(Me.cbo_Instrument) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Instrument] = '" & Me.cbo_Instrument & "'"
End If
DoCmd.OpenForm stDocName
DoCmd.Maximize
DoEvents 'Allow time for the form to open
Set frm = Forms!Review_frm_MainForm
Set sfrm = frm!frm_Instrument
sfrm.Filter = Whereclause
sfrm.FilterOn = True
Set sfrm = Nothing
Set frm = Nothing
When I run this code, I get a "Type Mismatch" error. Can anyone tell me where this error is coming from?
Thanks
Rene