show/hide controls when opening a form with another form

K

KRosier

Hi Everyone!
Any help on the following problem would be very much appreciated. I'm
using MSAccess 2000 and have just a smidgen of experience with coding -
enough to know that something can be done, but not enough to figure it
out quickly. Thanks!
Kathy

I have two forms
CharSelect_frm contains an unbound listbox containing names
char_frm contains name, registered, subform, label with text message

When I doubleclick on the name in CharSelect_frm, it opens char_frm and
goes to the related record (actually filters it so only one record is
showing).
I used this code in the listbox doubleclick event

DoCmd.OpenForm "char_frm", , , "charID=" & [Char_names]


I would like either the subform OR the label to be visible depending on
whether the person is registered or not.

If I open char_frm by itself the code in the char_frm Current event
works properly. However, if I use the CharSelect_frm to open the
char_frm, it always returns the subform as visible. I suspect it's a
matter of finding the proper event to place the code in, but I think
I've gone through them all.


Private Sub Form_Current()
If Me.Preg = 0 Then
Me.char_frm_sub.Visible = False
Me.register_lbl.Visible = True
Else
Me.char_frm_sub.Visible = True
Me.register_lbl.Visible = False
End If
 
K

Ken Snell [MVP]

Typically, I would use the Load event to make things visible/invisible when
a single record is being displayed. But I would use the Current event if I
can navigate between records and the visibility potentially needs to change
for each record.

If the code that you've posted isn't properly working, then I would guess
that the value of Me.Preg is incorrect when you open the form this way, or
that the subform has the focus when the form opens this way and therefore
the subform cannot be made invisible at that point, or that the code isn't
running correctly.
 
K

KRosier

Thank you Ken.

I neglected to mention that Preg is a Yes/No field. I had to set it to
= -1 and switch my true/false. Then it worked like a charm in the Load
event. Thanks for pointing me in the right direction.

Kathy
 

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