|
-
May 14th, 2006, 07:46 AM
#1
Thread Starter
Fanatic Member
[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
Last edited by Hack; May 16th, 2006 at 12:12 PM.
Reason: Added [RESOLVED] to thread title and green "resolved" checkmark
-
May 14th, 2006, 08:03 AM
#2
Re: Simple querry that stuck the programme.
Is your IssuedDateH filed will allow null/blank?
-
May 14th, 2006, 08:24 AM
#3
Thread Starter
Fanatic Member
Re: Simple querry that stuck the programme.
 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
-
May 14th, 2006, 10:16 AM
#4
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).
-
May 14th, 2006, 10:41 PM
#5
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).
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
May 15th, 2006, 09:41 AM
#6
Thread Starter
Fanatic Member
Re: Simple querry that stuck the programme.
 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
-
May 15th, 2006, 09:53 AM
#7
Re: Simple querry that stuck the programme.
 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?
-
May 15th, 2006, 09:57 AM
#8
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.
-
May 16th, 2006, 03:12 AM
#9
Thread Starter
Fanatic Member
Re: Simple querry that stuck the programme.
 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
-
May 16th, 2006, 03:18 AM
#10
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
Last edited by ganeshmoorthy; May 16th, 2006 at 03:19 AM.
Reason: Removed Else Block
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
May 16th, 2006, 03:28 AM
#11
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
-
May 16th, 2006, 08:56 AM
#12
Thread Starter
Fanatic Member
Re: Simple querry that stuck the programme.
Thanks for the help.
Seema_S
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|