dynamically display label and checkbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

the listbox on Form 1 has 5 options (populated from a table.) The choice is
used in filtering the second form and setting value of a textbox and it works
fine for all possible choices.

Additionally, if the choice is "instrument" I want to display additional
labels and checkboxes (on the 2nd form) They are already there,
Visible=False.

I test if the choice was "instrument" then can get a msgbox to appear
displaying the choice, which correctly says "instrument", so I know I'm on
the right track. I thought I should be able to add a line of code that sets
label.Visible=True, but nothing happens.

I do my initial filtering in the Open event of the form, so I tried the code
there, no luck. I moved it a few different places...no luck. What baffles
me is that I can get the Msgbox to show under the correct conditions but
can't get the next several lines of code to run...or so it seems

thanks for all your help!
MKMurphy
 
Discipline is a list of categories for the client, stored in a table used to
populate the lstDisc on Form1.


in the Form2 Open event:

DoCmd.ApplyFilter , Discipline = Form1.lstDisc.Value
DoCmd.GoToControl "txtDiscipline" --this txtbox serves as a title to
Form2; it's value is set to Form1.lstDisc

If txtDiscipline.Value = "Instrument" Then
MsgBox txtDiscipline.Value ---this runs and displays correctly, as in,
only when instruments are chosen, but not pipe or motor.

lblMechSignoff.Visible = True --these do not run
lblMechSignoff.Caption = "Installed"

lblElecSignoff.Visible = True
lblElecSignoff.Caption = "Tubed"

lblRotated.Visible = True
lblRotated.Caption = "Terminated"---to here
End If


thanks in advance for your time and trouble.
 
okay. you don't need the line

DoCmd.GoToControl "txtDiscipline"

unless you're planning to edit that control; it's not clear whether the
control has an expression as the ControlSource, if it does then you can't
edit the contents anyway.

as for the Visible property of a label, setting it will only have an effect
if the label is *not* connected to a control; if the label is linked to a
control, then the *control's* Visible property setting controls both the
control and its' associated label. however, if the labels are free-standing,
i don't see why the code wouldn't work. have you stepped through the code to
see what is actually happening?

also, a few other points. i'd probably set the label's Caption property
*before* making it visible. if you're not going to change or remove the
filter while in Form2, i'd suggest that instead of filtering the recordset
of Form2 after it's open, you either base the form on a query, or an
embedded SQL statement, that uses the value of lstDisc on Form1 as
criteria...or use a WHERE clause in the OpenForm code that opens Form2 from
Form1, with the value of lstDisc as criteria.

hth
 
actually, the labels are associated with the controls, which I do need to
display as well, so, following your advice, I changed it to

lblMechSignoff.Caption = "Installed"
MechanicalSignoff.Visible = True

don't know why I got off on the wrong path of trying to display the lbls
when I knew I had to do the checkboxes as well!

thanks ever so :o)
MKM
 
as for your other comments, which were very helpful...I am already basing the
form on a qry that uses the same lstValue as a criteria, so why the hell was
I doing it again? I deleted that line of code...thanks again! maybe I
shouldn't code so late!!
 
Back
Top