Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data type mismatch in criteria expression

Posted on 2006-07-15
5
Medium Priority
?
198 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
  • 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 21

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 21

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

916 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