Solved

Data type mismatch in criteria expression

Posted on 2006-07-15
5
189 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
Comment Utility
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
Comment Utility
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
Comment Utility
try saying

if value = vbnull then value = vbnullstring

The error could simply be the context of the null
0
 

Author Comment

by:MoJeaux39
Comment Utility
will do!  thank you!
0
 
LVL 20

Expert Comment

by:alainbryden
Comment Utility
Glad to have helped : )
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now