I hope someone can help. I am writing a call logging database with a VB front end that saves the information entered into an access database. I am connecting to the access database via a data control. The program was working up until yesterday however for some reason it has stopped saving the information into the access table. My program involves logging a call and then retrieving it later to update. Since my program stopped working I can log a call and as long as I don't log out of the program I can retrieve it by ref number (which is allocated using the autonumber function in access). However if I log out of the program I lose the information. It seems as if the program is storing the information somewhere in memory while it is running and not committing it to access. Please see below the parts of the code I am using to save the call to the access table. Hope someone can help.
Thanks Nick
option explicit
Dim myTable As Recordset
Dim MyWorkspace As Workspace
private sub form_load()
Set MyWorkspace = Workspaces(0)
Set myTable = Dattest.Recordset
MyWorkspace.BeginTrans
Dattest.Refresh
Dattest.Recordset.AddNew
lblPwRef.Caption = "PWR" + txtPwRef
Private Sub SaveRec_Click()
Dim temp As Variant
If txtName.Text = "" Then
MsgBox "Please complete call details"
ElseIf MsgBox("Save this call?", vbQuestion + vbYesNo, "Save Call") = vbYes Then
txtDateInWorkbasket = Format(Date, "dd/mm/yy")
txtTimeInWorkbasket = Left$(Time, 5)
temp = lblPwRef.Caption
Dattest.Recordset.Update
MyWorkspace.CommitTrans
Unload frmPaperwork
frmPaperworkMain.Show
MsgBox "Your call reference is " + temp, vbDefaultButton4 = vbOKOnly, "Call Reference Number"
Else
MyWorkspace.Rollback
MsgBox "You aborted logging call", vbOKOnly, "Aborted Call"
End If
End Sub
Thanks Nick
option explicit
Dim myTable As Recordset
Dim MyWorkspace As Workspace
private sub form_load()
Set MyWorkspace = Workspaces(0)
Set myTable = Dattest.Recordset
MyWorkspace.BeginTrans
Dattest.Refresh
Dattest.Recordset.AddNew
lblPwRef.Caption = "PWR" + txtPwRef
Private Sub SaveRec_Click()
Dim temp As Variant
If txtName.Text = "" Then
MsgBox "Please complete call details"
ElseIf MsgBox("Save this call?", vbQuestion + vbYesNo, "Save Call") = vbYes Then
txtDateInWorkbasket = Format(Date, "dd/mm/yy")
txtTimeInWorkbasket = Left$(Time, 5)
temp = lblPwRef.Caption
Dattest.Recordset.Update
MyWorkspace.CommitTrans
Unload frmPaperwork
frmPaperworkMain.Show
MsgBox "Your call reference is " + temp, vbDefaultButton4 = vbOKOnly, "Call Reference Number"
Else
MyWorkspace.Rollback
MsgBox "You aborted logging call", vbOKOnly, "Aborted Call"
End If
End Sub