I have record buttons on form for "Next", Previous", and "New", where I just use the below code with just the one command word change of acNext, acPrevious etc. in the button code. Note again, this code works in accdb but not in accde.
Code:
Private Sub NewButton_Click()
If CheckSave = False Then
Exit Sub
Else
DoCmd.GoToRecord , , acNewRec
End If
End Sub
Private Function CheckSave() As Boolean
CheckSave = True
If Me.Dirty Then
DoCmd.Beep
' "Save" dialog box with options Yes=1, No=2, Cancel=0
x = uDialog3(ErrorString(19), ErrorTitle(19))
If x = 1 Then
If IsNull(WeighType) Then
'MessageBox warning that transaction cannot be saved with [Weightype] left blank, or if
'[WeighType]=2, StorageInOut] has to have a value as well
uDialog ErrorString(33), ErrorTitle(33)
CheckSave = False
ElseIf WeighType = 2 And IsNull(StorageInOut) Then
uDialog ErrorString(34), ErrorTitle(34)
CheckSave = False
Else
RunCommand acCmdSaveRecord
'Sub that locks or unlocks text boxes on form depending on different statuses of transactions.
FmLock
End If
ElseIf x = 2 Then
RunCommand acCmdUndo
ElseIf x = 0 Then
CheckSave = False
End If
Else
CheckSave = True
End If
End Function