Hi Forum,
Does anyone have a simple VBA code for if the Combo Box Above was selected "Yes"; the form user must enter Details on Field Box (Make this Box Required)?
Thanks,
Hi Forum,
Does anyone have a simple VBA code for if the Combo Box Above was selected "Yes"; the form user must enter Details on Field Box (Make this Box Required)?
Thanks,
Very sketchy information.
Your combo box name is "Above"?? And you have a text box named "Field Box"??
And it's bound column contains the values Yes, or whatever (i.e. you're not showing Yes but the control is bound to some other column in its list)?
It is what type of form - main or sub form? When do you want to check this combo choice - when user clicks a button? Moves off of the record? Selects from the combo?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Sorry let me clarify.Very sketchy information.
Your combo box name is "Above"?? And you have a text box named "Field Box"??
And it's bound column contains the values Yes, or whatever (i.e. you're not showing Yes but the control is bound to some other column in its list)?
It is what type of form - main or sub form? When do you want to check this combo choice - when user clicks a button? Moves off of the record? Selects from the combo?
The is for mainform. The combo box (cbobox) is a "Yes","No" Value List. If "Yes" is selected then the field box (txtbox)below it is required to be entered.
Code:Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.cbobox = "Yes" and Nz(Me.txtbox,"") = "" Then Msgbox "txtbox Must Be Filled In!" Cancel = True txtbox.SetFocus End If End Sub
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
Not exactly sure what you are trying to do, but I will take a guess. It is my impression that you want to have a message that the user must use the combobox before something else can occur. There are a couple of ways that I do this in VB (I code in Visual Basic, but from past experience VBA is the same, just smaller).
I usually use a label with the property to .Visible = False. So here is the code I might use for the message:
With LabelMessage
.Visible = True
.Text = "You must make a selection from the Combobox above."
End With
The only question becomes where and how do you want the message executed and where and how do you want the label placed. In this case the content of the message would suggest the location of the message label.
I also might have the combobox enabled property set to False and then have some other event or routine that would enable the combobox and run the message at the same time. Then I would have another event routine disable the combobox and set the message label Visible property to False.
By the way, you do not need to use the With, End With. Something like this:
SomeEvent_()
'triggers Combobox and message
ComboBox.Enabled = True
MessageLabel.Visible = True
MessageLabel.Text = "Seriously, You really want to use this ComboBox?"
'Whatever else goes into the event
End Sub
SomeOtherEvent()
'Disable Combobox and lose message
ComboBox.Enabled = False
MessageLabel.Visible = False
'Whatever else goes into the event
End Sub
So all you would need to do is determine what event, subroutine or function you would want to trigger the message to be visible and what event, subroutine or function you want to trigger the message to disappear. Enable/Disable the combobox only if you think it would be beneficial to do so. Hope that addresses what you are wanting to do.