Getting a label to Requery!

B

Bob Vance

This code works on my form when I select "Yes" but if I open my Form and
"Yes" is Slected my Label lblCashSale is not Visible , lblCashSale has a No
Visible set
Thanks Bob

If cmbCashSale.value = "Yes" Then
lblCashOn.Visible = True

Else
lblCashOn.Visible = False
End If
 
S

Steve Schapel

Bob,

I assume you mean you have this code on the After Update event of the
combobox?

You might need to put similar code on the form's Current event as well.

By the way, you can shortcut to just one line of code:

Me.lblCashOn.Visible = Me.cmbCashSale = "Yes"
 
B

Bob Vance

Thanks Steve , I had to use mine in current yours was giving me an
error.........Thanks Bob

Private Sub Form_Current()
Me.cmbCashSale.Requery
If cmbCashSale.value = "Yes" Then
lblCashOn.Visible = True

Else
lblCashOn.Visible = False
End If
End Sub
 
S

Steve Schapel

I see, Bob. To take care of the situation where there is nothing
entered in the combobox, maybe you need:
Me.lblCashOn.Visible = Nz(Me.cmbCashSale, "") = "Yes"
 
M

miss

you don't speak french?


Bob Vance said:
Thanks Steve , I had to use mine in current yours was giving me an
error.........Thanks Bob

Private Sub Form_Current()
Me.cmbCashSale.Requery
If cmbCashSale.value = "Yes" Then
lblCashOn.Visible = True

Else
lblCashOn.Visible = False
End If
End Sub
 

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

Similar Threads


Top