|
-
Mar 14th, 2000, 04:46 PM
#1
Thread Starter
Registered User
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
-
Mar 16th, 2000, 03:45 PM
#2
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|