Visible True Or False: Don´t work

A

an

Hi!

I have a form with five comboboxes and correspondent five textboxes.
Each textbox, for default, show us "*" when form open.
After click in each combo, the correspondent texbox change to equal combo
data choosed.
I would like to show one command button, only after all five text boxes
changed to different of the "*".

In On Current procedure I have:
'Start code------
Private Sub Form_Current()

If txt1 <> "*" And _
txt2 <> "*" And _
txt3 <> "*" And _
txt4 <> "*" And _
txt5 <> "*" Then

cmdXPTO.Visible = True

Else

If txt1 = "*" Or _
txt2 = "*" Or _
txt3 = "*" Or _
txt4 = "*" Or _
txt5 = "*" Then
cmdXPTO.Visible = False
End If
End If
End Sub

'End code------

Don't work and don´t show us any error.
I would like your help for this, please.
Thanks in advance.
an
 
W

Wayne Morgan

Try:

If txt1 <> "*" And _
txt2 <> "*" And _
txt3 <> "*" And _
txt4 <> "*" And _
txt5 <> "*" Then

cmdXPTO.Visible = True

Else

cmdXPTO.Visible = False

End If
 
B

BruceM

Does it work when you navigate to a record? In other words, if you move to
a record in which all of the text boxes contain something other than *, is
the command button visible, and is the command button invisible when one of
the text boxes contains a *? If so, the code is working, but the form's
Current event only comes into effect when you first go to a record. If you
need the command button to become visible as soon as all of the text boxes
contain something other than *, one approach would be to enter the code into
a public sub, then call it as needed. With the form open in design view, go
to the VBA window. Click Insert > Sub. Choose Public and Sub, give it a
name (such as CommandVisible), and click OK. Enter the code into that sub.
Now in the form's Current event, and in the After Update event for each text
box, you can just use the line:

Call CommandVisible
 
S

Sandra Daigle

I suspect you need to execute the same code in the afterupdate events of
each combo. The current event is only going to show/hide the button as you
navigate between records.

You can put the code into a separate procedure and call it from the
afterupdate events and from the current event.
 
A

an

SD,
Sorry for my delay.

Exactly! Your solution work fine.
Thanks for help.

an

Sandra Daigle said:
I suspect you need to execute the same code in the afterupdate events of
each combo. The current event is only going to show/hide the button as you
navigate between records.

You can put the code into a separate procedure and call it from the
afterupdate events and from the current event.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

WM

Thanks for your replay.
I tried. Don't work too.
(?)
an
 
A

an

BM,

Thanks for your explanation.
an

BruceM said:
Does it work when you navigate to a record? In other words, if you move to
a record in which all of the text boxes contain something other than *, is
the command button visible, and is the command button invisible when one of
the text boxes contains a *? If so, the code is working, but the form's
Current event only comes into effect when you first go to a record. If you
need the command button to become visible as soon as all of the text boxes
contain something other than *, one approach would be to enter the code into
a public sub, then call it as needed. With the form open in design view, go
to the VBA window. Click Insert > Sub. Choose Public and Sub, give it a
name (such as CommandVisible), and click OK. Enter the code into that sub.
Now in the form's Current event, and in the After Update event for each text
box, you can just use the line:

Call CommandVisible
 
P

PJones

The current event only fires once each record. You need to put your code in
a sub-routine and call it on the after-update event of each combo box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top