Results 1 to 12 of 12

Thread: [RESOLVED] Simple querry that stuck the programme.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Resolved [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:
    1. With rs
    2.  .AddNew
    3.   .Fields("IssuedDateH").Value = CDate(txtIssuedDateH.Text)
    4.  .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

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Simple querry that stuck the programme.

    Is your IssuedDateH filed will allow null/blank?
    CS

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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).

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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:
    1. If txtExpiryDate.Text <> "" Then
    2.    .Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
    3.    Else
    4.     txtExpiryDate.Text = vbNull
    5.  End If

    Seema_S

  10. #10
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Simple querry that stuck the programme.

    Seema: try this
    VB Code:
    1. If IsDate(txtExpiryDate.Text) Then
    2.    .Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
    3. 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.


  11. #11
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    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:
    1. If txtExpiryDate.Text <> "" Then
    2.     .Fields("ExpiryDate").Value = CDate(txtExpiryDate.Text)
    3. Else
    4.     .Fields("ExpiryDate").Value  = Null
    5. End If
    Frans

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    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
  •  



Click Here to Expand Forum to Full Width