Results 1 to 2 of 2

Thread: problems with AddNew method - cant get code right?/|#!

  1. #1

    Thread Starter
    Registered User
    Join Date
    May 1999
    Location
    Melbourne, Victoria, Australia
    Posts
    47

    Post

    I'm trying to write code to add a new record to a form with a text box on it . Once the user clicks the Total text box a message comes up stating that they "must start a new invoice peroid now". I want to add some code following clicking O.K to this message that will automatically start a new record. I keep getting errors like recordset not defined. Can somebody give me some directions please?

    The database is called Selecttest2
    The table is called Mailing List

    Regards Paul

  2. #2
    Hi,

    Try the following:

    - Insert a module.
    - In the module type the following:
    Dim Db As Database.
    Dim Rec As RecordSet.
    - In the forms Form_Load() event, type the following:
    Set Db=DbEngine.WorkSpaces(0)._
    OpenDatabase("Selecttest2.mdb")
    Set Rec = Db.OpenRecordSet("Mailing List")
    - In your TextBox Click() event, type the following:
    Rec.AddNew
    Rec("Mailing List") = "" ' You set the contents of the record as you like any time anywhere in the program.
    Rec.Update

    - Don't forget before your terminate your program, you have to type the following where feel it's appropriate:
    Db.Close

    Hope this helps,

    Wesam

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