Use of Default Value property

  • Thread starter Thread starter AimeeK via AccessMonster.com
  • Start date Start date
A

AimeeK via AccessMonster.com

Hi, I have a form in which I have a combo box in which if a user selects
"Yes", the corresponding text box becomes visible and the default value
(which was set up at the table level) reads "Enter details here". If the
combo box selection is "No", then the box goes away, which is what I want to
happen. However, if a user selects "Yes", enters some details into the text
box, but then realizes they've made an error, and goes back and selects "No",
then the corresponding text box retains the values they started entering
instead of resetting back to the default value of "Enter details here". Is
there a way to reset this using code within the combo box's After Update
event and the DefaultValue property?

Let me know if you need more detail...thanks in advance for your help.
 
Code would be something like this (assumes that the textbox is bound to the
field in the table, and that you're starting a new record when this action
is being done):

Private Sub ComboBoxName_AfterUpdate()
If Me.ComboBoxName.Value = "Yes" Then
Me.TextBoxName.Visible = True
Else
Me.TextBoxName.Visible = False
End If
End Sub
 
Aimee-
the default value at the table level is going to set the field to 'Enter
details here' when a new record is created, but once that happens it stops
doing anything. Yes, the after update of the combobox would be a good place
to do what you want. You can put:
me.NameOfTextBox = "Enter Details Here"
right before or after you make the textbox invisible. Not sure of exactly
what you're doing, but hope this solves your problem
-John
 
Hi,
clear the default value and just set the value within vba code on the after
update event of the combobox:

If Me.YourCombo.Value = "Yes" Then
Me.YourControl.Value = "What Ever"
Me.YourControl.Visible = True
Else
Me.YourControl.Visible = False
End If

Something like this.
HTH
Good luck
 
Back
Top