After a lot of trial and error, I've got it working using a boolean, as below:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
Dim myForm As Form
Set myForm = Me.Form
Dim inStorage As Boolean
inStorage = False
inStorage = inStorage Or Me.cboEquipmentStatus.Value = 2
inStorage = inStorage Or Me.cboEquipmentStatus.Value = 3
For Each ctl In myForm
If InStr(1, ctl.Tag, "*") <> 0 Then
If ctl.Value <> ctl.OldValue Then
Me.txtDateUpdated = Date
End If
End If
If InStr(1, ctl.Tag, "&") <> 0 Then
If inStorage And ctl.Value <> ctl.OldValue Then
If MsgBox("WARNING!! Changing Equipment status to In Storage will remove all Logial Equipment Information as well as the Room its assigned to." _
& " Are you sure you want to proceed?", vbYesNo) = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
Call toStorage
Me.txtDateUninstalled = Date
MsgBox "Uninstalled Date Updated"
Else
Me.Undo
End If
ElseIf Not inStorage And ctl.Value <> ctl.OldValue Then
Me.txtDateInstalled = Date
MsgBox "installed date updated"
End If
End If
Next
End Sub
Private Sub toStorage()
Me.cboBuildingName = ""
Me.cboRoomName = ""
Me.cboCabinetName = ""
Me.txtEquipmentName = ""
Me.txtEquipmentIP = ""
Me.cboEquipmentNetworkType = ""
Me.cboSoftwareVersion = ""
End Sub
Hopefully you can understand my code. Right now, I'm trying to empty all the cbo and txt boxes in Private Sub toStorage. It was telling me I need to save the record first. So I added "DoCmd.RunCommand acCmdSaveRecord" However, that doesn't work either. it gives me this error:
...What can I do about that? Should I be using OnDirty instead of Before Update?