Here is an example of adding a record to an Access table, and updating a record in Access. It requires an ODBC connection to the database.
'Update Record
Set cn = CreateObject("ADODB.Connection") '***'
Set rs = CreateObject("adodb.recordset")
cn.Open "db1.mdb", "Admin", "Password"
strSQL = "UPDATE [T-Card Main] SET "
If TextTrailer1.Text = "" Then
strSQL = strSQL & "[Trailer Number] = Null "
Else
strSQL = strSQL & "[Trailer Number] = '" & TextTrailer1.Text & "' "
End If
strSQL = strSQL & "WHERE [Pronumber] = " & TextPronumber.Text
Set rs = cn.Execute(strSQL)
cn.Close
'Add a new record
Set cn = CreateObject("ADODB.Connection") '***'
Set rs = CreateObject("adodb.recordset")
cn.Open "db1.mdb", "Admin", "Password"
varInsert1 = "INSERT INTO [EventLog] ([Pronumber], [Event], [EventDateTime], [EnteredBy]) "
varInsert1 = varInsert1 & "VALUES (" & TextPronumber.Text & ", '" & "Order Entered" & "', "
varInsert1 = varInsert1 & "#" & Now() & "#, '" & FormRTI.varUserName & "')"
sSQL = varInsert1
'MsgBox (sSQL)
Set rs = cn.Execute(sSQL)
cn.Close