calling a form

M

Maracay

HI guys

I have a form call frmMasterData in this form I have a option group called
FramePrePostSort and a command button to execute another form frmImpData.

I shouldn’t be able to execute the form frmImpData if some of the options of
FramePrePostSort are not selected, how can I do that?

Thanks
 
L

Linq Adams via AccessMonster.com

"if some of the options of FramePrePostSort are not selected"

This is somewhat ambiguous. If you mean if ***certain*** options are selected,
you can call the form but if certain ***other*** options are not, you can't
call it, then

Private Sub FramePrePostSort_AfterUpdate()

Select Case Me.FramePrePostSort
Case 1, 4
cmdCallfrmImpData.Enabled = True
Case 2, 3
cmdCallfrmImpData.Enabled = False
Case Else
cmdCallfrmImpData.Enabled = False
End Select

End Sub

You'll need to place the same code in the Form_Current event as well.

If you mean that you only want to be able to call the form if an option (any
option) is selected, then all you need is code in the Form_Current event:

If IsNull(Me.FramePrePostSort) Then
cmdCallfrmImpData.Enabled = False
Else
cmdCallfrmImpData.Enabled = True
End If
 
M

Mr B

Just a question or two:

You did not indicate if the frame control is bound to a data field or not.
If the frame is bound then the selected option will be selected when the form
loads, but if your frame control is not bound, then you should set a default
value for your group frame control. If you set the default value to Null the
option buttons inside the control will appear greyed and neither selected or
unselected when the form loads. If you set the default value of the frame
control to zero then all of the options inside the frame will be unselected
when the form opens and your user will have to make a selection.

Linq's code would be fine if the default value of your control is Null.
However, if the default value of your control is set to zero then you would
just set the command button to disabled and then in the After Update event of
your frame control, use this code:

if me.FramePrePostSort = 0 Then
cmdCallfrmImpData.Enabled = False
Else
cmdCallfrmImpData.Enabled = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top