Solved

Data type mismatch in criteria expression

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
A macro to Count the number of rows across all worksheets 3 95
Spell Check in VB6 13 114
fso.FolderExists("\\server\HiddenFolder$") 4 66
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

810 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