A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

type mismatch error 13



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2009, 08:35 AM posted to microsoft.public.access
jon
external usenet poster
 
Posts: 640
Default type mismatch error 13

hi,

I am using Allen Browne advance filter code:

Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#dd\/mm\/yyyy\#"

If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & "([vacationdate] = " & Format(Me.txtStartDate,
conJetDate) & ") AND "
End If

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & "([vacationdate] " & Format(Me.txtEndDate +
1, conJetDate) & ") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen = 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND
" at the end.
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True

End If

but the msg "type mismatch error 13" shows & highlighted at the line:

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & "([vacationdate] " & Format(Me.txtEndDate +
1, conJetDate) & ") AND "
End If

Please help???
  #2  
Old July 6th, 2009, 11:44 AM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default type mismatch error 13

Firstly, do not change the const to match your own regional settings. Leave
it the way JET expects the format, i.e.:
Const conJetDate = "\#mm\/dd\/yyyy\#"
Explanation:
http://allenbrowne.com/ser-36.html

Secondly, the code assumes that txtEndDate contains a value of type Date. It
won't work if it contains a non-date, such as a string.

Perhaps you cleared the date programmatically with:
Me.txtEndDate = ""
where you should have had:
Me.txtEndDate = Null

Provided you set the Format property of the text box to a date format (e.g.
General Date), you won't be able to enter a non-date value into the control,
so make sure you don't assign a non-date value to the unbound control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jon" wrote in message
...
hi,

I am using Allen Browne advance filter code:

Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#dd\/mm\/yyyy\#"

If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & "([vacationdate] = " & Format(Me.txtStartDate,
conJetDate) & ") AND "
End If

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & "([vacationdate] " & Format(Me.txtEndDate +
1, conJetDate) & ") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen = 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND
" at the end.
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True

End If

but the msg "type mismatch error 13" shows & highlighted at the line:

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & "([vacationdate] " & Format(Me.txtEndDate +
1, conJetDate) & ") AND "
End If

Please help???


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.