Results 1 to 3 of 3

Thread: Trouble using AddNew

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Location
    Brisbane, Australia
    Posts
    17

    Trouble using AddNew

    Hi Again,

    I am attempting to create a record on click of my add button.
    I am not using DAO.

    I am not really sure how to go about assigning values to the DB fields but this is what I am doing....

    Set myDB1 = OpenDatabase("c:\Defects\Defects97.mdb")
    Set rst1 = myDB1.OpenRecordset("Select * From MajorComponents")
    rst1.AddNew Array("MajorComponent", "AltComponent", "TailNumber", "SnapShotDate", "Descriptor", "ScreenShotLocation"), Array("combo1.Text", "combo2.Text", "combo3.text", "text1.text", "File1.Path & '\' & File1.FileName", "text2.text")

    The error I get is ... Wrong number of arguments or invalid property assignment.

    I'd appreciate some help on this.

    Cheers

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hmm never seen it done this way... what i would do is something like this:

    VB Code:
    1. Set rst1 = myDB1.OpenRecordset("Select * From MajorComponents")
    2. rst1.AddNew
    3.      rst1("MajorComponent") = Combo1.Text
    4.      rst1("AltComponent") = Combo2.Text
    5.      rst1("TailNumber") = Combo3.Text
    6.      rst1("SnapShotDate") = Text1.Text
    7. rst1.Update 'ommit if using ADO
    -= a peet post =-

  3. #3
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    335
    the way u open your database is actually
    telling me that u are using DAO

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