Below is the VBA code I'm using to update the comment. I would have to make a lot of deletions/changes to upload the database but I don't think it would help. All I need to do is refrseh the data in the forms frm_WIPcomments and frm_short_WIP.
Private Sub Command30_Click()
Dim err As Integer
Dim cnn2 As ADODB.Connection
Dim tblWIPcomments As ADODB.Recordset
Dim strCnn As String
'Check that all fields are filled in
txt_addcomment_comment.SetFocus
If txt_addcomment_comment = "" Then
err = err + 1
MsgBox "Please insert a comment!" & err
End If
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn2 = New ADODB.Connection
mydb = "C:\FS and WS management.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
cnn2.Open strCnn
' Open contact table.
Set tblWIPcomments = New ADODB.Recordset
tblWIPcomments.CursorType = adOpenKeyset
tblWIPcomments.LockType = adLockOptimistic
tblWIPcomments.Open "tblWIPcomments", cnn2, , , adCmdTable
'get the new record data
tblWIPcomments.AddNew
tblWIPcomments!tblWIPcomments_ord = txt_addcomment_ord
tblWIPcomments!tblWIPcomments_commentdate = txt_addcomment_date
tblWIPcomments!tblWIPcomments_comment = txt_addcomment_comment
tblWIPcomments!tblWIPcomments_interiminv = cbx_addcomment_interiminv
tblWIPcomments!tblWIPcomments_finalinv = cbx_addcomment_finalinv
tblWIPcomments!tblWIPcomments_time = txt_addcomment_time
tblWIPcomments!tblWIPcomments_User = txt_addcomment_user
tblWIPcomments.Update
'refreshes other forms
[Forms]![frm_WIPcomments].Requery
[Forms]![frm_short_WIP].Requery
' Show the newly added data.
MsgBox "New comment on service order " & tblWIPcomments!tblWIPcomments_ord & " has been successfully added, and the form will now close"
'close connections
tblWIPcomments.Close
cnn2.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
'Closes open form
DoCmd.Close acForm, "frm_addwipcomment", acSaveYes
End Sub