Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch on Form 3

Status
Not open for further replies.

mkrets

Technical User
Aug 28, 2007
15
US
I've got a form with a start date and an end date field that I'm trying to use to apply a filter to a sub form. I used a snippet of code from the FAQ that looks like:

Code:
strFilter = "" 'Start with a blank filter
'Verify the both ends of the start date range are valid
If (IsDate(Me![txtStartDate]) & IsDate(Me![txtEndDate])) Then
   'Build the filter
   strFilter = "([DateAdded] between #" _
      & Me![txtStartDate] & "# AND #" _
      & Me![txtEndDate] & "#)"

When I click the 'Apply Filter' button I get a "Type mismatch" error which then highlights:

Code:
If (IsDate(Me![txtStartDate]) & IsDate(Me![txtEndDate])) Then

I can't see anywhere that I don't have the field types set up incorrectly. Any other ideas as to where this error might be coming from?
 
It's a "Runtime Error '13'" if that helps.
 
what are the values of txtstartdate and txtenddtae

ck1999
 
I would guess that one or both of your controls contains a Null value.

 
The values are dates. In that particular instance they were:

Start: 1/21/2008
End: 1/31/2008
 
OH, I missed the obvious. You are using a concatenation operator instead of AND

If (IsDate(Me![txtStartDate]) And IsDate(Me![txtEndDate])) Then


 
I have another question related to this. If I want to create a button to clear this filter and reset the combo boxes that control it, what is the best way to do that?

I'm currently using:

Code:
Private Sub btnClearFilters_Click()

    Me![frmSubActivity].Form.Filter = ""
    Me![cboCategory].Value = ""
    Me![cboSubcategory].Value = ""
    Me![cboUserID].Value = ""
    
End Sub

That seems to be a little buggy. When I recreate filters after I've cleared an existing filter sometimes I get no records displayed even though I know there should be.
 
How are ya mkrets . . .

Have a look at the [blue]Filter On[/blue] property! . . . you won't have to click [blue]Apply/Remove[/blue] filter!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
mkrets said:
I have another question related to this
That's ok, I wasn't expecting a thank you or anything for answering your first question. Just keep asking your questions. We are here to serve.


 
In answer to the second question, I changed to "Null" instead of "" and that fixed the filtering issue.

THANK YOU for all of the help gents. Stars all around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top