After Update on combo confusing me

  • Thread starter Jay974 via AccessMonster.com
  • Start date
J

Jay974 via AccessMonster.com

I have a form which is used to capture various information on our customers.
There is a combobox which records the type of business. The row source of the
combobox is based on a table with 1st column as PK (autonumber) and second
column as text. The combobox has the first column bound with a 0cm width.

I also have a text field which is set to visible=no . This should only be set
to yes if the value of the bound column in the combobox is less than three. I
have used the following code in the after update of the combobox, but I can't
seem to see why it won't work

If Me.cboBusinessType < 3 Then Me.txtRegNo.Visible = True And Me.Label47.
Visible = True

When I step through when the combobox has the second selection, I get me.
cboBusinessType = "2", but this doesn't show the two fields I want.

It's probably something stupidly simple, but can a fresh pair of eyes
possibly tell me where I am going wrong?

Thanks
 
B

Brendan Reynolds

Jay974 via AccessMonster.com said:
I have a form which is used to capture various information on our
customers.
There is a combobox which records the type of business. The row source of
the
combobox is based on a table with 1st column as PK (autonumber) and second
column as text. The combobox has the first column bound with a 0cm width.

I also have a text field which is set to visible=no . This should only be
set
to yes if the value of the bound column in the combobox is less than
three. I
have used the following code in the after update of the combobox, but I
can't
seem to see why it won't work

If Me.cboBusinessType < 3 Then Me.txtRegNo.Visible = True And Me.Label47.
Visible = True

When I step through when the combobox has the second selection, I get me.
cboBusinessType = "2", but this doesn't show the two fields I want.

It's probably something stupidly simple, but can a fresh pair of eyes
possibly tell me where I am going wrong?

Thanks


Its the "And", it doesn't work that way. Its doing a logical And of True and
the value of the Visible property of the label, which will evaluate to False
unless the label is already visible. In other words, your code is doing
something like this ...

fTemp = (True And (Me.Label47.Visible=True))
'fTemp now holds the value True if Label47 is visible, or False if Label47
is not visible)
Me.txtRegNo.Visible = fTemp

Try something like this instead ...

If Me.cboBusinessType < 3 Then
Me.txtRegNo.Visible=True
Me.Label47.Visible=True
End If
 
J

Jay974 via AccessMonster.com

Thanks Brendan, that works exactly as I need. Much appreciated.
 

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