0
votes

I'm very new to Access VBA and am trying to open an access report based on two input text boxes and a combo box input.

This form consists of 2 unbound Start date and End date text boxes based on the Claim Process Date column; and there is a combobox to select the Customer name.

I'm trying to create a button which opens the report based on these three criteria, but I get a mismatched data type error.

Private Sub Command51_Click()

Dim strCriteria As String
strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "#" And "[Customer Name] = '" & Me.Combo49 & "'"

DoCmd.OpenReport "CustomerClaims", acViewPreview, strCriteria
End Sub

Any suggestion would be appreciated. Thank You

1
What's in Me.Combo49 ?Nimeshka Srimal
I don't know VBA, but I just feel that you should be calling "[Customer Name] = '" & Me.Combo49.Value ?Nimeshka Srimal
Me.Combo 49 has Customer names, and tried using Me. Combo49.Value, it still doesn't filter out the customersCindy

1 Answers

0
votes

And was left out of the query/quotes, and there's a missing space.

strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & _
    Me.txtEndDate & "#" And "[Customer Name] = '" & Me.Combo49 & "'"

becomes (see 2nd line)

strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & _
    Me.txtEndDate & "# And [Customer Name] = '" & Me.Combo49 & "'"