I am currently building a form and I have used the controlsource on the properties of the textboxes to link them to a table. My problem is now I want to put in a msgbox in the “afterupdate” to confirm if a person wants to save a change or not.
If MsgBox("Save these changes?", vbYesNo) = vbYes Then
.Update
Else
.CancelUpdate
End If
Obviously the .update doesn’t work becaues I have no record set in the code
Is there away of doing this I tried coding it below
I also tried to code in a database and recordset but I can’t link the textboxes to the table
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblDetails"
I tried coding in the control source but still no success.
Forms!frmEntry.RecordSource = "tblDetails"
Me!txtProductLine.ControlSource = rst![ProductLine]
I also put code into the buttons e.g.
Private Sub bttPrev_Click()
On Error GoTo Err_bttPrev_Click
rst.MovePrevious
Exit_bttPrev_Click:
Exit Sub
Err_bttPrev_Click:
MsgBox Err.Description
Resume Exit_bttPrev_Click
End Sub
But this gives me errors too
I’m sure this code worked for me years ago but I can’t remember how to do it. I would be very grateful if someone could refresh my memory before I go insane
If MsgBox("Save these changes?", vbYesNo) = vbYes Then
.Update
Else
.CancelUpdate
End If
Obviously the .update doesn’t work becaues I have no record set in the code
Is there away of doing this I tried coding it below
I also tried to code in a database and recordset but I can’t link the textboxes to the table
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblDetails"
I tried coding in the control source but still no success.
Forms!frmEntry.RecordSource = "tblDetails"
Me!txtProductLine.ControlSource = rst![ProductLine]
I also put code into the buttons e.g.
Private Sub bttPrev_Click()
On Error GoTo Err_bttPrev_Click
rst.MovePrevious
Exit_bttPrev_Click:
Exit Sub
Err_bttPrev_Click:
MsgBox Err.Description
Resume Exit_bttPrev_Click
End Sub
But this gives me errors too
I’m sure this code worked for me years ago but I can’t remember how to do it. I would be very grateful if someone could refresh my memory before I go insane