When you get the Compile Error, what line is it complaining about? Does the
error have any other details in it?
I see your declaration for strConstraint. Have you declared stDocName as
well?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I did not explain very good...
Everything Wayne explained is fine: But, now I need to add another combo
boxe.
Taking what you suggested below and adding a combo box called "status"
This gives me a Compile Error..
What am I doing worng???
Dim strConstraint As String
strConstraint = "[TR_INQUIRYTYPE]=" & Me.InqType & " AND " & _
"[TR_STATUS] = " & Me.status
stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acViewPreview, , strConstraint
:
Hard-coding it in the DoCmd, as Wayne illustrated, may not be
appropriate in
that case, but coding it for the DoCmd still probably is.
Dim strConstraint As String
strConstraint = "[InquiryType]=" & Me.InqType & " AND "& _
"[StartDate] = " & Format(Me.StartDate, "\#mm\/dd\/yyyy\#") & "
AND "
_
"[EndDate] = " & Format(Me.EndDate, "\#mm\/dd\/yyyy\#")
DoCmd.OpenReport stDocName, acViewPreview,, strConstraint
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
This is good if I have only one combo box...
And it does answer my question...
But I have to add two more combo boxes - so coding it in the DoCmd
does
not
seem likethe right place...
How would I add 2 more combo boxes????
Thanks
:
What is the data type of the field in the drop down (combo box) that
the
value is coming from? The code is the same, but the syntax changes
slightly
depending on the data type.
Assuming a number data type:
DoCmd.OpenReport stDocName, acViewPreview,, "[FieldName]=" &
Me.InqType
Assuming a text data type:
DoCmd.OpenReport stDocName, acViewPreview,, "[FieldName]=""" &
Me.InqType &
""""
Put in the correct field name for the field you want to filter.
--
Wayne Morgan
MS Access MVP
In the below code "InqType" is a dropdown.
The reports needs to show only those files that match the field
choosen in
the dropdown.
Could someone please help me.
If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
ElseIf IsNull(Me.InqType) Then
MsgBox "You Must Enter an Inquiry Type."
Else
DoCmd.OpenReport stDocName, acPreview
End If