Hiding a label

D

davwhsdb

I'm very new to VB coding and Access databases in general, so this is a
very basic question.

I created a form and linked it to a header table. The primary key of
the header table is accessed through a combo box on the form. When a
key is chosen from the from, I want the form to look for a specific
value in a second table that also uses the same key, and based on that
value (it's a check box, so true/false), I want a label to be visible
or invisible.

I'm pretty sure the code for this goes into the OnChange event of the
combo box, but I don't know the syntax to access the second form.

Hopefully that's enough info to gain a response, but if not I can
clarify.

Thanks,
Dave
 
A

Allen Browne

Try putting a text box on your form, with a Control Source like this:
=IIf(IsNull(DLookup("ID", "Table2",
"ID = " & Nz([Combo1], 0)), Null, "Show this text")

That assumes:
- The combo is named Combo1.
- Its Bound Column refers to a field of type Number.
- The other table is called Table2.
- It has a primary key named ID, which matches the combo's value.
 
R

Ron2006

If it truely is a label that you want to be seen or not seen then

In the afterupdate (or change event) of the field AND the oncurrent
event of the form

if IsNull(DLookup("ID", "Table2","ID = " & Nz([Combo1], 0)) then
me.labelname.visible = false
else
me.labelname.visible = true
endif

Ron
 

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