Solved

Data type mismatch in criteria expression

Posted on 2006-07-15
5
194 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 23 hours left to enroll

626 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