[RESOLVED] Simple querry that stuck the programme.
Hi,
Sometimes I need to keep blank the "ExpiryDate" textbox (txtExpiryDate). How can I do this. The present code doesnt allow me to save data until I enter this textbox.
VB Code:
With rs
.AddNew
.Fields("IssuedDateH").Value = CDate(txtIssuedDateH.Text)
.Update
Regards.
Seema_s
Re: Simple querry that stuck the programme.
Is your IssuedDateH filed will allow null/blank?
Re: Simple querry that stuck the programme.
Quote:
Originally Posted by cssriraman
Is your IssuedDateH filed will allow null/blank?
I think it needs to be set to null to allow save other data. Could you please rewrite the same code to accept null values?
Regards.
Seema_S
Re: Simple querry that stuck the programme.
To set a field (in a new record) to Null, just don't set it to anything.
Use an If statement to check if there is text in the textbox - if there is, set the field value (otherwise dont set it).
Re: Simple querry that stuck the programme.
If the problem is that the database doesn't allow null inputs for that field, you'll have to change that in the database (if you really want to allow null date entries).
Re: Simple querry that stuck the programme.
Quote:
Originally Posted by Al42
If the problem is that the database doesn't allow null inputs for that field, you'll have to change that in the database (if you really want to allow null date entries).
In the database it is like the following:
Required - No
Indexed - No
Though I am getting error when any textbox has null value.
Seema_S
Re: Simple querry that stuck the programme.
Quote:
Originally Posted by seema_s
In the database it is like the following:
Required - No
Indexed - No
Though I am getting error when any textbox has null value.
Seema_S
Yes, but, does it allow NULLS? What is the error that you are getting?
Re: Simple querry that stuck the programme.
"Required - No" is the Access equivalent of "Allow Nulls".
The problem is in the VB code - the required correction is explained in my post above.
Re: Simple querry that stuck the programme.
Quote:
Originally Posted by si_the_geek
"Required - No" is the Access equivalent of "Allow Nulls".
The problem is in the VB code - the required correction is explained in my post above.
Hi,
But, the below code is not working:
VB Code:
If txtExpiryDate.Text <> "" Then
.Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
Else
txtExpiryDate.Text = vbNull
End If
Seema_S
Re: Simple querry that stuck the programme.
Seema: try this
VB Code:
If IsDate(txtExpiryDate.Text) Then
.Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
End If
Re: Simple querry that stuck the programme.
Don't use vbNull but Null. Also don't set the text property of the textbox to null, because this is not possible. You should set the field to Null.
VB Code:
If txtExpiryDate.Text <> "" Then
.Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
Else
.Fields("ExpiryDate").Value = Null
End If
Re: Simple querry that stuck the programme.
Thanks for the help.
Seema_S