Originally Posted by
mike60smart
Hi
I created a copy of your SearchQ Form and named it frmSearchResult
I removed the criteria from SearchQ
Then I modified the OnClick Event on your SearchS Form
hello mike
Thank you very much for your help.
I replaced my code with your code and my problem was solved.
Can you please explain what is the difference between these two codes and what is the function of your third code with if statement.
Thanks again.
My code
Code:
Dim strwhere As Integer
strwhere = "Offerdate BETWEEN #" & Me.cbxStart & "# And #" & Me.cbxend & "#"
DoCmd.OpenForm "searchf2", acNormal, , strwhere
DoCmd.Close acForm, "searchs"
Your's Code
Code:
Dim strCrit As String
If IsDate(Me.cbxStart) Then
strCrit = strCrit & "([OfferDate] >= #" & Format(Me.cbxStart, "mm/dd/yyyy") & "#) AND "
End If
If IsDate(Me.cbxend) Then
strCrit = strCrit & "([OfferDate] <= #" & Format(Me.cbxend, "mm/dd/yyyy") & "#) AND "
End If
If strCrit > "" Then
strCrit = Left(strCrit, Len(strCrit) - 5)
DoCmd.OpenForm "searchf2", acNormal, , strCrit
DoCmd.Close acForm, "searchs"
End If