Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data type mismatch in criteria expression

Posted on 2006-07-15
5
Medium Priority
?
197 Views
Last Modified: 2010-04-30
Hi,
I'm using vbscript in an html page to write to an access 2000 db.  Added form validation so that if one form field is empty, its corresponding date should also be blank.   However, I am unable to submit a null value to the db... I'm getting the Data type mismatch in criteria experssion.

Checked the db for date fields & there is no 'allow zero length string' setting.  The field setting was set to 'not required'.

Is there away around this?  Do I have to use 99/99/9999?   You help is appreciated!  I've assigned 500 pts due to urgency.  Thanks!  


Sample of the validation code:
form31 = main.REQ1.value
If IsEmpty(main.REQ1.value) Then
         form31 = "NONE"
      ElseIf len(main.REQ1.value) = 0 Then
         form31 = "NONE"
      Else
         form31 = main.REQ1.value
      End If
form32 = main.DTORD1.value
If IsEmpty(main.DTORD1.value) Or (form31) = "NONE" Then
         form32 = Null
      ElseIf len(main.DTORD1.value) = 0 Then
         form32 = Null
      Else
         form32 = main.DTORD1.value
      End If
form33 = main.DTREC1.value
If IsEmpty(main.DTREC1.value) Or (form31) = "NONE" Then
         form33 = Null
      ElseIf len(main.DTREC1.value) = 0 Then
         form33 = Null
      Else
         form33 = main.DTREC1.value
      End If
0
Comment
Question by:MoJeaux39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17115543
Why pass in null, why dont u not bother specifying it in your insert/update statement

What data type is the field u are trying to set

0
 

Author Comment

by:MoJeaux39
ID: 17115565
DATE/TIME

I'm inserting 94 fields.... quite long.   What exactly would I need to add to the INSERT statement that would prevent it from inserting if the value were null?
0
 
LVL 20

Accepted Solution

by:
alainbryden earned 2000 total points
ID: 17115656
try saying

if value = vbnull then value = vbnullstring

The error could simply be the context of the null
0
 

Author Comment

by:MoJeaux39
ID: 17116075
will do!  thank you!
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 17116144
Glad to have helped : )
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question