Hello,
I think my best solution is to create an unbound form, which will be more work now, but I wanted to ask:
I have an entry form which I want to save only with a save button, and otherwise, do not. It has an autonumber I'd like to remain consistent. I've tried the following:
Code:
[Private Sub Form_Unload(Cancel As Integer) 'this undoes changes to forms before it is closed/unloaded
If MsgBox("This entry hasn't been saved. Are you sure?", vbYesNo + vbDefaultButton2, "Confirmation") = vbNo Then
Cancel = True
Else
Me.Undo
End If
End Sub
However, I think this leaves a blank because an auto number is assigned once any textbox is updated. Using if me.dirty then DoCmd.RunCommand acCmdUndo in place of me.undo in the code above works, but it but deletes the autonumber entry entirely
I've tried preventing form updates via the following (where buttonpressed = true when save button is clicked):
Code:
Private Sub Form_Current()
ButtonPressed = False
End Sub
Dim ButtonPressed as Boolean
Private Sub Form_BeforeUpdate(Cancel As Integer) 'Cancel update, unless buttonpressed (save button) = true'
If ButtonPressed = False Then Cancel = True
End Sub
But this causes issues when I have to reference control.text instead of control.value for some other vba i have filling out the text boxes. Does anyone have any thoughts on this? Thank you so much for any help. I'm new to access and hopefully can contribute to answering here some day.