[RESOLVED]Error when updating database-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED]Error when updating database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    365

    Resolved [RESOLVED]Error when updating database

    I'm using ADO commands, VB 6.0, and MS Office 2000

    Below is the code I am using to update my database. I'm testing a single field first so it's just one line of code.

    VB Code:
    1. With Form2.rs
    2.     .AddNew
    3.         .Fields("fldEmpGender") = cmbGender.Text
    4.     .Update
    5. End With

    When I do this I get the an error saying...

    Run-time error '-bunch of numbers':

    The field 'tblEmployee.fldEmpPassword' cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field.
    I don't get this error. My test database only has 3 employees in it and they all have passwords already entered in the fldEmpPassword table/database.

    After I hit 'OK' it highlights the .Update line in yellow.
    Last edited by lilmark; Apr 20th, 2006 at 04:45 PM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Error when updating database

    You tried to add a new Employee Record but did not specify the password. As the error states the password is required and cannot be Null.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    365

    Re: Error when updating database

    Quote Originally Posted by brucevde
    You tried to add a new Employee Record but did not specify the password. As the error states the password is required and cannot be Null.
    I hate the obvious.
    I was trying to edit a current record. I didn't mean to add a new one.
    To edit I would only to delete the .addnew from my current coding, right? Or is there some edit coding I need to include?

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

    Re: Error when updating database

    You were right, for ADO nothing is needed - an edit is implied as soon as you set/change values.

    (for DAO you need to specify an edit)

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Re: Error when updating database

    Quote Originally Posted by lilmark
    I'm using ADO commands, VB 6.0, and MS Office 2000

    Below is the code I am using to update my database. I'm testing a single field first so it's just one line of code.

    VB Code:
    1. With Form2.rs
    2.     .AddNew
    3.         .Fields("fldEmpGender") = cmbGender.Text
    4.     .Update
    5. End With

    When I do this I get the an error saying...



    I don't get this error. My test database only has 3 employees in it and they all have passwords already entered in the fldEmpPassword table/database.

    After I hit 'OK' it highlights the .Update line in yellow.
    Remove the .AddNew if you only want to update...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.