Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbyes/no not working correctly

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I have a form with various check boxes. if one checkbox is selected it throws a warning if you select yes then all checkboxes will be cleared. This part works just fine, however if you click no to cancel it it seems to work, but when you try to go to another control on the form or advance to the next record it throws the alert again. It seems it is not canceling truely. my code is below

Private Sub blnallowidcheckout_BeforeUpdate(Cancel As Integer)
'Checks group checkboxes and if any are checked gives vbyesno message box
'if yes is selected all checkboxes are cleared
'if no selected nothing happens
Debug.Print blnallowidcheckout
If blnbstseai Or blnbstsmts Or blnbstsdb Or blnbstsests _
Or blnbsmo Or blnbsstaff Or blnbsabap Or blnbschangesup _
Or blnbsfinance Or blnbscommkt Or blnbssupply Or blnsstools _
Or blnsseim Or blnbsqrrc Then

Dim intResponse As Integer
Dim strPrompt As String

strPrompt = "Clear all enabled checkboxes for Groups Allowed to Checkout ID?"

intResponse = MsgBox(strPrompt, vbYesNo + vbDefaultButton2)

If intResponse = vbYes Then

blnbstseai.Value = False
blnbstsmts.Value = False
blnbstsdb.Value = False
blnbstsests.Value = False
blnbsmo.Value = False
blnbsstaff.Value = False
blnbsabap.Value = False
blnbschangesup.Value = False
blnbsfinance.Value = False
blnbscommkt.Value = False
blnbssupply.Value = False
blnsstools.Value = False
blnsseim.Value = False
blnbsqrrc.Value = False
blnioiptel.Value = False
blniopcm.Value = False
blniocts.Value = False
blnionts.Value = False
blnioeurope.Value = False
blnioasia.Value = False
blniobrazil.Value = False


Else

MsgBox blnallowidcheckout
Cancel = True

End If
End If
End Sub
 
Yes, cancelling the before update event of a control, means to "go back to the control as it was when you attempted to leave it" - i e the change is performed but not "saved to the control".

So, for nothing "to happen", you might want to just remove the cancel = true? Or perhaps use a undo on the control?

Roy-Vidar
 
I have tried removing the cancel = true and it works to a point, but it removes the checkbox true on the checkbox when they say no or yes now. I have tried to reapply the value if they say now and get a debug error. the undo command does not work either.
 
Dunno, I don't have the overall picture of the code, but perhaps seems a bit more like after update code in stead of before update of the control? You could perhaps also just set the control value to false (after update)

Roy-Vidar
 
got it working. your clue of after update was correct.. I ended up getting to check the values of the checkboxes and if any of them were true to renable to original checkbox.

Thanks..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top