Empty Date field is cashing....

qaaccess

Registered User.
Local time
Today, 11:50
Joined
Jul 23, 2014
Messages
18
When user enter the data other than date field or when date field remain empty and user press the Add button, it is giving error.

(Error 3075)

Syntax Error in date in query expression '#'.

while same code is working for text field. but it is not working for date field.

If (Me.rdate) = "" Then

Exit Sub

End If

Please help. thanks.
 
Have you tried:
If IsNull(Me.rdate) Then

Exit Sub

End If
 
You could also try the IsDate() function.
See here for details.
 
Have you tried:
If IsNull(Me.rdate) Then

Exit Sub

End If

Yes i have tried the following: it does not giving the error but at the same time it is not inserting the data into text field using this code. user wants to enter only in text field and does not want to enter the date, then text field data should be saved/insert into table, but it is not saving.

If (Me.Desc) = "" Then

Exit Sub

End If

If IsNull(Me.rdate) Then

Exit Sub

End If[
 
Show us the full code, not just snippets. And please enclose them in code tags:

This is complete code. As i am new in programming.

Private Sub updt_Click()

If Not IsNumeric(Me.rejqty) = True Then
MsgBox ("Please Enter the Rejected Quantity in Number(s)")

Me.rejqty.SetFocus

Exit Sub
End If



If (Me.ccid) = "" Then

Exit Sub

End If


If IsNull(Me.stdate) Then

Exit Sub

End If



If (Me.rejqty) = "" Then

Exit Sub

End If


If (Me.Desc) = "" Then

Exit Sub

End If


If IsNull(Me.descdate) Then

Exit Sub

End If



If (Me.rcause) = "" Then

Exit Sub

End If


If IsNull(Me.rdate) Then

Exit Sub

End If



If (Me.scontain) = "" Then

Exit Sub

End If


If IsNull(Me.shdate) Then

Exit Sub

End If



If (Me.lcontain) = "" Then

Exit Sub

End If


If IsNull(Me.ldate) Then

Exit Sub

End If



If (Me.caimp) = "" Then

Exit Sub

End If


If IsNull(Me.cadate) Then

Exit Sub

End If



If (Me.qplan) = "" Then

Exit Sub

End If


If IsNull(Me.qdate) Then

Exit Sub

End If



If (Me.verify) = "" Then

Exit Sub

End If


If IsNull(Me.vdate) Then

Exit Sub

End If


CurrentDb.Execute "Insert INTO tblNCM(CCID, Startdate, ItemID, Rejqty, Description, Descdate, Rootcause, Rootdate, Shortcontain, Shortdate, Longcontain, Longdate, CAImplementation, CAImpdate, Qualityplan, Qualitypdate, Verification, Verifdate)" & _
" Values ( '" & Me.ccid & "' , #" & Me.stdate & "# , '" & Me.pnumlist & "' , " & Me.rejqty & " , '" & Me.Desc & "' , #" & Me.descdate & "# , '" & Me.rcause & "' , #" & Me.rdate & "# , '" & Me.scontain & "' , #" & Me.shdate & "# , '" & Me.lcontain & "' , #" & Me.ldate & "# , '" & Me.caimp & "', #" & Me.cadate & "# , '" & Me.qplan & "', #" & Me.qdate & "# , '" & Me.verify & "' , #" & Me.vdate & "#)"
 
Use what is in the link and re-copy and paste your code again. Your code should look like this:
Code:
If IsNull(Me.vdate) Then
    Exit Sub
End If
... can you see how much easier it is to read?
 
Use what is in the link and re-copy and paste your code again. Your code should look like this:
Code:
If IsNull(Me.vdate) Then
    Exit Sub
End If
... can you see how much easier it is to read?

You mean i have to use tag as following ?

Code:
With me

If IsNull(Me.vdate) Then     

     Exit Sub 

End If

End with

[\code]
 
Yes, but re-copy it from your db and past it back.

And the closing tag is [/code], not [\code]
 
Yes, but re-copy it from your db and past it back.

And the closing tag is [/code], not [\code]

Getting following error after using the tags.

Run-time error '2465':

Microsoft Access can't find the field '|1' referred to in your expression.
 
I'm talking about pasting code here on the site. You use code tags on the site not in Access. Just like the screenshot shows in the link.
 
Anyway, to check if a date field/textbox bound to a date field is Null or not use the IsDate() function.
 
Anyway, to check if a date field/textbox bound to a date field is Null or not use the IsDate() function.
Here is the following code.
Code:
Private Sub updt_Click()

If Not IsNumeric(Me.rejqty) = True Then
MsgBox ("Please Enter the Rejected Quantity in Number(s)")

 Me.rejqty.SetFocus
  
  Exit Sub
  End If
  


If (Me.ccid) = "" Then

Exit Sub

End If


If IsNull(Me.stdate) Then

Exit Sub

End If



If (Me.rejqty) = "" Then

Exit Sub

End If


If (Me.Desc) = "" Then

Exit Sub

End If


If IsNull(Me.descdate) Then

Exit Sub

End If



If (Me.rcause) = "" Then

Exit Sub

End If


If IsNull(Me.rdate) Then

Exit Sub

End If



If (Me.scontain) = "" Then

Exit Sub

End If


If IsNull(Me.shdate) Then

Exit Sub

End If



If (Me.lcontain) = "" Then

Exit Sub

End If


If IsNull(Me.ldate) Then

Exit Sub

End If



If (Me.caimp) = "" Then

Exit Sub

End If


If IsNull(Me.cadate) Then

Exit Sub

End If



If (Me.qplan) = "" Then

Exit Sub

End If


If IsNull(Me.qdate) Then

Exit Sub

End If



If (Me.verify) = "" Then

Exit Sub

End If


If IsNull(Me.vdate) Then

Exit Sub

End If


CurrentDb.Execute "Insert INTO tblNCM(CCID, Startdate, ItemID, Rejqty,  Description, Descdate, Rootcause, Rootdate, Shortcontain, Shortdate,  Longcontain, Longdate, CAImplementation, CAImpdate, Qualityplan,  Qualitypdate, Verification, Verifdate)" & _
" Values ( '" & Me.ccid & "' , #" & Me.stdate & "# , '"  & Me.pnumlist & "' , " & Me.rejqty & " , '" &  Me.Desc & "' , #" & Me.descdate & "# , '" & Me.rcause  & "' , #" & Me.rdate & "# , '" & Me.scontain & "' ,  #" & Me.shdate & "# , '" & Me.lcontain & "' , #" &  Me.ldate & "# , '" & Me.caimp & "', #" & Me.cadate &  "# , '" & Me.qplan & "', #" & Me.qdate & "# , '" &  Me.verify & "' , #" & Me.vdate & "#)"
 
Ok, but I've already answered your question, you need to use the IsDate() function.
 
Ok, but I've already answered your question, you need to use the IsDate() function.
Thanks Issue has been resolved.

Now the next thing is.


Is it possible to load the data in input from by double clicking on data from list box ?

I have single form on which both input form and read-only form is present. as i used visible property to display or not accordingly.

User enters the data from input form. (It has been done)

User go onto read only form where combo box and list box. from drop down values load into list-box. (It has been done)

Now double click on any record then it should re-directed on input form with loading the data in editable mode for updation purpose. ???? (How this step will be done) ???
 

Users who are viewing this thread

Back
Top Bottom