Hi..I need a help on my looping:
In the main form, I have textbox MID=M123456 and CAV=4
In sub form,
a. I have CID and DateTime.
b. I add MCID =Count(MID)
I want to do a looping for CID <= CAV
if >4,msgbox "More than CAV" then undo
if <>4,msgbox "Less than CAV" then MID will lock and not allow to change
Below is my code but not work
Private Sub Form_BeforeUpdate(Cancel As Integer)
Do Until Me.CMID < Forms![Navigation form]![NavigationSubform].[Form]![MCAV]
Me.CAVITY = Forms![Navigation form]![NavigationSubform].[Form]![MCAV]
Me.DATETIME = Now()
DoCmd.Save
Loop
MsgBox "MORE THAN MODEL CAVITY..."
DoCmd.RunCommand acCmdUndo
End Sub
In the main form, I have textbox MID=M123456 and CAV=4
In sub form,
a. I have CID and DateTime.
b. I add MCID =Count(MID)
I want to do a looping for CID <= CAV
if >4,msgbox "More than CAV" then undo
if <>4,msgbox "Less than CAV" then MID will lock and not allow to change
Below is my code but not work
Private Sub Form_BeforeUpdate(Cancel As Integer)
Do Until Me.CMID < Forms![Navigation form]![NavigationSubform].[Form]![MCAV]
Me.CAVITY = Forms![Navigation form]![NavigationSubform].[Form]![MCAV]
Me.DATETIME = Now()
DoCmd.Save
Loop
MsgBox "MORE THAN MODEL CAVITY..."
DoCmd.RunCommand acCmdUndo
End Sub