GIJoeFigure
Technical User
I'm having a problem using DoCmd.ApplyFilter to retrieve from a dataset. My code is below.
Private Sub Execute_Click()
Dim WhereClause As String
WhereClause = ""
'Each toggle turns off and on a different column to search
If Me!ProToggle = True Then
WhereClause = WhereClause & "[ViewPosition] = '" & Me![ViewPosition] & "' AND "
End If
If Me!ttToggle = True Then
WhereClause = WhereClause & "[DataType] = '" & Me![DataType] & "' AND "
End If
If Me!ICToggle = True Then
WhereClause = WhereClause & "[ImageComments] = '" & Me![ImageComments] & "' AND "
End If
If Me!BPToggle = True Then
WhereClause = WhereClause & "[BodyPartExamined] = '" & Me![BodyPartExamined] & "' AND "
End If
If Me!PPToggle = True Then
WhereClause = WhereClause & "[PatientPosition] = '" & Me![PatientPosition] & "' AND "
End If
If Me!IToggle = True Then
WhereClause = WhereClause & "[InstitutionName] = '" & Me![InstitutionName] & "' AND "
End If
If Me!FPToggle = True Then
WhereClause = WhereClause & "[DataPath] Like '*\" & Me![DataPath] & "*' AND "
End If
'Chop off the last AND
If Len(WhereClause) > 0 Then
WhereClause = Left(WhereClause, Len(WhereClause) - 4)
End If
resp = MsgBox(WhereClause & "Is this correct?", vbYesNoCancel)
' Now use the completed where statement to filter table entries
If resp = 2 Then Exit Sub
If resp = 7 Then
WhereClause = InputBox("What is the statement changes you would like?", , WhereClause)
End If
DoCmd.ApplyFilter WhereClause
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, its made to set up variable length whereclauses for the filter to use butI keep getting a runtime error saying that the last line doesn't work because my form is not bound to a table or query. Does anybody know how to solve what its asking for? Thanks in advance
J. Handfield
Interning Scientist
Eastman Kodak Research Labs
Rochester, NY 14650
Private Sub Execute_Click()
Dim WhereClause As String
WhereClause = ""
'Each toggle turns off and on a different column to search
If Me!ProToggle = True Then
WhereClause = WhereClause & "[ViewPosition] = '" & Me![ViewPosition] & "' AND "
End If
If Me!ttToggle = True Then
WhereClause = WhereClause & "[DataType] = '" & Me![DataType] & "' AND "
End If
If Me!ICToggle = True Then
WhereClause = WhereClause & "[ImageComments] = '" & Me![ImageComments] & "' AND "
End If
If Me!BPToggle = True Then
WhereClause = WhereClause & "[BodyPartExamined] = '" & Me![BodyPartExamined] & "' AND "
End If
If Me!PPToggle = True Then
WhereClause = WhereClause & "[PatientPosition] = '" & Me![PatientPosition] & "' AND "
End If
If Me!IToggle = True Then
WhereClause = WhereClause & "[InstitutionName] = '" & Me![InstitutionName] & "' AND "
End If
If Me!FPToggle = True Then
WhereClause = WhereClause & "[DataPath] Like '*\" & Me![DataPath] & "*' AND "
End If
'Chop off the last AND
If Len(WhereClause) > 0 Then
WhereClause = Left(WhereClause, Len(WhereClause) - 4)
End If
resp = MsgBox(WhereClause & "Is this correct?", vbYesNoCancel)
' Now use the completed where statement to filter table entries
If resp = 2 Then Exit Sub
If resp = 7 Then
WhereClause = InputBox("What is the statement changes you would like?", , WhereClause)
End If
DoCmd.ApplyFilter WhereClause
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, its made to set up variable length whereclauses for the filter to use butI keep getting a runtime error saying that the last line doesn't work because my form is not bound to a table or query. Does anybody know how to solve what its asking for? Thanks in advance
J. Handfield
Interning Scientist
Eastman Kodak Research Labs
Rochester, NY 14650