View Text box based on combo box selection

fibayne

Registered User.
Local time
Today, 11:18
Joined
Feb 6, 2005
Messages
236
Hi..On a form I have various combo box's which are part of a questionnaire, I am trying to open a particular text box when each choice is made eg if the user selects 'No' form the combo a text/memo fileld becomes visible for them to explain their answer ....have tried searching but not having much luck..any help woudl be greatly appreciated as ever :confused:
cheers

Fi
 
you can try something like:

Code:
If Me.ComboName = "No" Then
Me.TextboxName.Visible = True
Else
Me.TextboxName.Visible = False
End If
 
Hi maxmangion..thanks for your reply, I have oput your code int he AfterUpdate event on the combo and it is sort of working, if I select No nothing happens but if I close the form and reopen the Text Box is visible ?? also if I select Yes it does disappear, should I change the settign on the text box ? I have visible set to Yes at the moment...many thanks Fi
 
if I close the form and reopen the Text Box is visible ??

you can put the code on the onCurrent event of the form as well, so that when you open the form and the first record is shown, based on the value in the combo the textbox will be visible or not.
 
Hi maxmangion...I have come across code given to me a while back from this forum...which I have adapted to make this work, i also changed that it was to open a text box to opening a subform, still building up the rest of the subforms needed but here is the code working so far

Private Sub ShowSubForm()


'-- First make all of the SubFormControls invisible.
Me.frmFeeCollectable.Visible = False
Me.frmFeeCollectableDate.Visible = False

'Display appropriate subform based on MediaType chosen
Select Case Me.cboAmountCollectable

Case "Yes"
Me.frmFeeCollectableDate.Visible = True
Case "No"
Me.frmFeeCollectable.Visible = True
Case "In Part"
Me.frmFeeCollectable.Visible = True
Case "Deferred"
Me.frmFeeCollectable.Visible = True



Case Else
'-- Do nothing - they're all invisible

End Select

End Sub

Private Sub ShowSubForm1()

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If cboAmountCollectable = "Yes" Then
Me.frmFeeCollectableDate.Visible = True
Me.frmFeeCollectable = False


ElseIf cboAmountCollectable = "No" Then
Me.frmFeeCollectableDate.Visible = False
Me.frmFeeCollectable = True


ElseIf cboAmountCollectable = "In Part" Then
Me.frmFeeCollectableDate.Visible = False
Me.frmFeeCollectable = True

ElseIf cboAmountCollectable = "Deferred" Then
Me.frmFeeCollectableDate.Visible = False
Me.frmFeeCollectable = True


Else
Me.frmFeeCollectableDate.Visible = False
Me.frmFeeCollectable = False

End If

End Sub

Private Sub cmdClose_Click()

'Close form
DoCmd.Close

End Sub


Private Sub Form_Current()

'Call subroutine to display appropriate subform based on AmountCollectable
Call ShowSubForm

End Sub


Private Sub cboAmountCollectable_AfterUpdate()

'Call subroutine to display appropriate subform based on MediaType
ShowSubForm

End Sub


thans for your help.....cheers Fi
 
you're welcome and i am glad that you solved your problem. Just one thing which i would change is

Code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 because

with

Code:
DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom