Linking controls in form design

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Hi I am trying to figure out how one can have a
combo/text box appear when clicking on a check box? I
suppose I must put some code into the check box to do
this, although there is no wizard to help me.
So for example, one may click on "credit card" as their
method of payment (from money order, cheque, credit card,
etc) and when this happens, a combo box appears and gives
the options of amex, visa, bankcard, etc. I'd very much
appreciate help, thanks,

- Matt
 
"Matt" said:
Hi I am trying to figure out how one can have a
combo/text box appear when clicking on a check box? I
suppose I must put some code into the check box to do
this, although there is no wizard to help me.
So for example, one may click on "credit card" as their
method of payment (from money order, cheque, credit card,
etc) and when this happens, a combo box appears and gives
the options of amex, visa, bankcard, etc. I'd very much
appreciate help, thanks,

- Matt

Matt

Firstly, you need to create the required controls manually in the form, and set
their Visible property to False.

Then, in the OnClick event for the Check Box, you need some code to set these
controls to be visible:

Private Sub txtCard_Click()
If Me!txtCard = True Then
Me!cboCardType.Visible = True
Else
Me!cboCardType.Visible = False
End If
End Sub

And finally, you also need some code in the OnCurrent event, which happens when
you move between records, to hide these controls if needed:

Private Sub Form_Current()
If Me!txtCard = True Then
Me!cboCardType.Visible = True
Else
Me!cboCardType.Visible = False
End If
End Sub
 
Hi I am trying to figure out how one can have a
combo/text box appear when clicking on a check box? I
suppose I must put some code into the check box to do
this, although there is no wizard to help me.

Set the VISIBLE property of the Combo Box to False. Then put code in
the AfterUpdate event of the checkbox:

Private Sub chkCreditCard_AfterUpdate()
If chkCreditCard = True Then
Me!cboCardType.Visible = True
Else
Me!cboCardType.Visible = False
End If
End Sub

or, more elegantly,

Private Sub chkCreditCard_AfterUpdate()
Me!cboCardType.Visible = (Me!chkCreditCard)
End Sub

You'll also want to put code in the Form's Current event to set
cboCardType.Visible to Me!chkCreditCard so it will disappear again
when you move to a new record, and appear or disappear depending on
the value of the yes/no field in existing records.
 
Back
Top