W
Will
I get a compile error: else without if error message from this code. Tried
and tried removing ifs and end ifs and all Thens are at the end of the line.
Can anyone tell me what's wrong with it?
Private Sub btnSave_Click()
On Error GoTo Err_btnSave_Click
If Me!Status > 4 And Me!Quantity <> Me!OldQuantity Then 'After Confirmed
can't edit quantity
MsgBox "Cannot edit quantity of PO when already ordered, but up
to 20% + or - can be booked in", , "Purchase Order"
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
ElseIf Me!Status < 5 And Me!Quantity < (Me!OldQuantity * 0.8) Then
'Reducing below 20% permitted
MsgBox "Quantity reduced by more than 20 %", , "Purchase Order"
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, ,
A_MENU_VER20
End If
ElseIf Me!Quantity > (Me!OldQuantity * 1.2) Then
MsgBox "Quantity increased by more than 20 %, Status is now
amended and awaits reauthorisation", , "Purchase Order"
Me.Status = 1 'If increased by more than 20% status becomes new
and needs to be authorised
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, ,
A_MENU_VER20
End If
Else
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, , A_MENU_VER20
MsgBox "Edit of PO is now saved", , "Purchase Order"
DoCmd.Close
End If
Exit_btnSave_Click:
Exit Sub
Err_btnSave_Click:
MsgBox Error$
Resume Exit_btnSave_Click
Thanks in advance
and tried removing ifs and end ifs and all Thens are at the end of the line.
Can anyone tell me what's wrong with it?
Private Sub btnSave_Click()
On Error GoTo Err_btnSave_Click
If Me!Status > 4 And Me!Quantity <> Me!OldQuantity Then 'After Confirmed
can't edit quantity
MsgBox "Cannot edit quantity of PO when already ordered, but up
to 20% + or - can be booked in", , "Purchase Order"
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
ElseIf Me!Status < 5 And Me!Quantity < (Me!OldQuantity * 0.8) Then
'Reducing below 20% permitted
MsgBox "Quantity reduced by more than 20 %", , "Purchase Order"
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, ,
A_MENU_VER20
End If
ElseIf Me!Quantity > (Me!OldQuantity * 1.2) Then
MsgBox "Quantity increased by more than 20 %, Status is now
amended and awaits reauthorisation", , "Purchase Order"
Me.Status = 1 'If increased by more than 20% status becomes new
and needs to be authorised
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, ,
A_MENU_VER20
End If
Else
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH, , A_MENU_VER20
MsgBox "Edit of PO is now saved", , "Purchase Order"
DoCmd.Close
End If
Exit_btnSave_Click:
Exit Sub
Err_btnSave_Click:
MsgBox Error$
Resume Exit_btnSave_Click
Thanks in advance