I'm using the following code to copy information from a text box in word to a database in Access. I don't get any errors but none of the information in the text boxes gets entered into my database. Can someone help me with this?
Thanks
Dim db As Database
Dim rs As Recordset
Selection.GoTo What:=wdGoToBookmark, Name:="clientsTop"
Selection.Text = FirstName.Text & " " & LastName.Text
Selection.GoTo What:=wdGoToBookmark, Name:="address"
Selection.Text = Address.Text & ", " & City.Text & ", " & State.Text & ", " & ZipCode.Text
'Insert Information into the Database
Set db = OpenDatabase("C:\LoneStar\db1.mdb")
' open the database
Set rs = db.OpenRecordset("Client Info", dbOpenTable)
' get all records in a table
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("First Name") = FirstName.Text
.Fields("Last Name") = LastName.Text
.Fields("Home Number") = HomeNo.Text
.Fields("Email Address") = Email.Text
.Fields("Home Address") = Address.Text
.Fields("City") = City.Text
.Fields("State") = State.Text
.Fields("Zip") = ZipCode.Text
End With
Thanks
Dim db As Database
Dim rs As Recordset
Selection.GoTo What:=wdGoToBookmark, Name:="clientsTop"
Selection.Text = FirstName.Text & " " & LastName.Text
Selection.GoTo What:=wdGoToBookmark, Name:="address"
Selection.Text = Address.Text & ", " & City.Text & ", " & State.Text & ", " & ZipCode.Text
'Insert Information into the Database
Set db = OpenDatabase("C:\LoneStar\db1.mdb")
' open the database
Set rs = db.OpenRecordset("Client Info", dbOpenTable)
' get all records in a table
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("First Name") = FirstName.Text
.Fields("Last Name") = LastName.Text
.Fields("Home Number") = HomeNo.Text
.Fields("Email Address") = Email.Text
.Fields("Home Address") = Address.Text
.Fields("City") = City.Text
.Fields("State") = State.Text
.Fields("Zip") = ZipCode.Text
End With