If and When problem

colinmunnelly

Registered User.
Local time
Today, 16:58
Joined
Feb 26, 2002
Messages
89
I want a text field to become invisible when a combo box has a null value selected. I have set the text box visible fiels to 'No' and placed this small peice of code in the 'Form_Current' section.

If Combo10 = null then
Txtname.visible = true
else
Txt.visible = false

End if
End sub

But this is not working. Anyone help?
 
Colin what about puting the code on click of the combo box? This works for me when I need to to disable other combos depending on the value chosen in the first combo.

Hay
 
problem

Could do although i still can't understand why its not working on current. Within the text field i have a Dlookup statement would this have anything to do with it? God don't ya just hate these silly problems. Using the on click method it would need the user to actually activate that combo box when it would be much easier setting default no null. Am i right in thinking that code should work?
 
Colin I am a little confused in your first post you say you have set the text box fields to visible = false but this would only mean this control would not be shown on the form have you set the default value to = null? and is null an item in your combo box? I am still very much on a learning curve with VBA but my understanding is that the code you have above is going to look for a value you have selected in the combo the act accordingly. If you set the default value of the combo box to null then it might work your way.
 
Aaahh

No still no luck. I can't understand why the code doesn't work when the combo is null!
 
a couple of points:

Firstly, putting the code on the On Current event of the form ensures that the control is made visible (or not) as you move from one record to another - it will not reveal/hide the control if the combo is altered. You need the After Update event of the combo for this.

Also, there's a small error in your code ...

If Combo10 = null then

the above line should be

If IsNull([Combo10]) then
etc.

HTH

Jeff
 
I think you are only asking for the text boxes not to be shown upon opening then shown when an item is chosen from the combo yes?

If I have misunderstood you please let me know

You'll need to set the control source to unbound as well

Hay
 

Attachments

Last edited:
Not really Hayley. All i want is in effect to be able to scroll through records and if that particular combo box is populated the text boxes are visible.
 
Try this in the form current

Private Sub Form_Current()
If IsNull([combo]) Then

Text1.Visible = False
Text2.Visible = False

Else

Text1.Visible = True
Text2.Visible = True

End If
End Sub

think thats what your after

HTH
Dave.

PS G,Day Hayley.
 
Hello Dave

how are you and hows things in Austrailia? Like your new avator very nice it's almost as good as mine
 
Here you go Dave.

Great to see someone flying the flag. :)

Brad
 

Attachments

  • aus.gif
    aus.gif
    10.2 KB · Views: 138

Users who are viewing this thread

Back
Top Bottom