Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a record to Access Table from Word

Status
Not open for further replies.

ohmbru2

Technical User
Jul 24, 2001
51
US
I'm trying to populate an access table from Word. I have a custom button in a Word document. It does some tasks, but I want to capture some info in an Access table as part of the process.

I only need to add one record, then do the other tasks. I need help with code to open the DB, open the table, add a record, then close the DB.
 
Code:
' TOOLS -> REFERENCES -> MICROSOFT DAO 3.6 LIBRARY

Private Const DBNAME As String = "C:\Documents and Settings\WinblowsME\Desktop\MasterCard.mdb"

Sub Update_DB()
   Dim db As Database, rs As Recordset
   
   Set db = OpenDatabase(DBNAME)
   Set rs = db.OpenRecordset("tblCustomers")

   rs.AddNew
   rs.Fields("Credit_Card_No") = "1111 1111 1111 1111"
   
   rs.Update
   
   rs.Close
   db.Close
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top