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 Wanet Telecoms Ltd 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 in a Table with VBA 1

Status
Not open for further replies.

danvzla

Programmer
Jan 16, 2004
28
FI
How can I add a new record in a Table using VBA. I Tried with this code, it seems to work because in the msgbox I can see the 1234 value. The problem is that when I open the table the chage is not save. Do I need to save the record at the end. How do I do that? Thank!!


Private Sub NewRNWButton_Click()

Dim rst As New ADODB.Recordset
rst.Open "LogDatafill_Table_NORCROSS",_ CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rst.Fields("ID").Value = 1234
MsgBox (rst("ID"))

End Sub
 
Try adding - rst.update

i.e.
Dim rst As New ADODB.Recordset
rst.Open "LogDatafill_Table_NORCROSS",_ CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rst.Fields("ID").Value = 1234
MsgBox (rst("ID"))
rst.update


Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top