Help with Code

  • Thread starter Thread starter Musa via AccessMonster.com
  • Start date Start date
M

Musa via AccessMonster.com

I have the following code in an Event Procedure (On_ClicK). Command133 is a
Macro that calls upon the next form(while closing the current form). This
should be disabled as long as any of the option groups = -1. The problem I
have is the enable and disable of the Macro (Command133).
I want to Disable Command133 while the individual is completing all the
fields on the form and then Enable Command133 after all Options have been
competed.

Private Sub Command176_Click()
If (Me.Combo156) And (Me.opt41) And (Me.opt42) And (Me.opt43) And (Me.opt44)
And (Me.opt45) And (Me.Frame46) = -1 Then
Me.Command133.Enabled = False
MsgBox "You missed a Question. Please check your selections"
Cancel = True
Else
Me.Command133.Enabled = True
MsgBox "You may proceed to the next page"
Exit Sub
End If
End Sub
 
I would approach it a little differently. I would make the command button
disabled in design view. Then I would check the values in the form Before
Update event and enable the button if all option groups have the correct
value.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.Combo156) = True And (Me.opt41) = True And (Me.opt42) = True And
(Me.opt43) = True And Me.opt44) = True And (Me.opt45) And (Me.Frame46) = True
Then
MsgBox "You missed a Question. Please check your selections"
Cancel = True
Else
Me.Command133.Enabled = True
MsgBox "You may proceed to the next page"
End If
End Sub

Also, to reset the command button for each record, disable it in the form
Current Event.
 
Back
Top