label toggled by command button

G

Guest

We have a main form with several subforms linked to it, and a button at the
bottom (New Session) to advance to the new main form record. Is there a way
to have a label somewhere in the form, or even outside the form, pop up when
the New Session button is clicked to remind the user to go to a certain field
first?

Could we toggle the label visible in the OnClick event of the button? (does
it matter that this already has code associated with it?)

Thanks for any help! I'm new to coding, so I will need someone to walk me
through it if it's possible.

Christine
 
F

fredg

We have a main form with several subforms linked to it, and a button at the
bottom (New Session) to advance to the new main form record. Is there a way
to have a label somewhere in the form, or even outside the form, pop up when
the New Session button is clicked to remind the user to go to a certain field
first?

Could we toggle the label visible in the OnClick event of the button? (does
it matter that this already has code associated with it?)

Thanks for any help! I'm new to coding, so I will need someone to walk me
through it if it's possible.

Christine

You could have the label on the form set to Visible = False.
Then, if the button is on the same form as the label, code the command
button click event:

' Coding here is OK.
Me![LabelName].Visible = True
' Additional code here is OK.

If the button is on a subform and the label on the Main Form, use:
Me.Parent![LabelName].Visible = True

But then it will be visible continuously unless you have code
elsewhere to make it not visible again.

Why do you need to remind the user to go to a particular control?
Why not just set the focus to that control directly from the command
button:
If the button and control are on the same form:
[SomeControl].SetFocus
or if the button is on the sub form and the control on the Main Form:
Me.Parent![SomeControl].SetFocus
 
G

Guest

We need this certain field filled in because it's the primary key, and we've
noticed that if you go to the subforms and start entering data there first,
it won't let you go back to the main form to fill that in, or gives the error
messages about null value in the primary key.

I haven't used the focus before-- will that just put the cursor into the
field you want it to after clicking?

Thanks!
Christine
fredg said:
We have a main form with several subforms linked to it, and a button at the
bottom (New Session) to advance to the new main form record. Is there a way
to have a label somewhere in the form, or even outside the form, pop up when
the New Session button is clicked to remind the user to go to a certain field
first?

Could we toggle the label visible in the OnClick event of the button? (does
it matter that this already has code associated with it?)

Thanks for any help! I'm new to coding, so I will need someone to walk me
through it if it's possible.

Christine

You could have the label on the form set to Visible = False.
Then, if the button is on the same form as the label, code the command
button click event:

' Coding here is OK.
Me![LabelName].Visible = True
' Additional code here is OK.

If the button is on a subform and the label on the Main Form, use:
Me.Parent![LabelName].Visible = True

But then it will be visible continuously unless you have code
elsewhere to make it not visible again.

Why do you need to remind the user to go to a particular control?
Why not just set the focus to that control directly from the command
button:
If the button and control are on the same form:
[SomeControl].SetFocus
or if the button is on the sub form and the control on the Main Form:
Me.Parent![SomeControl].SetFocus
 
J

Jeff C

Rabbit said:
We need this certain field filled in because it's the primary key, and we've
noticed that if you go to the subforms and start entering data there first,
it won't let you go back to the main form to fill that in, or gives the error
messages about null value in the primary key.

I haven't used the focus before-- will that just put the cursor into the
field you want it to after clicking?

Thanks!
Christine
:
Hi Rabbit,

Set focus to the control and then on lost focus put a if routine.

If isDirty (Me.fieldname) then
msgbox "You must add an identity code here!"
Me.fieldname.Setfocus
End If

Hope this helps!

Jeff C.
 
G

Guest

Thank you! OK, newbie here. I'm confused about where to put the code...

Do you mean to set the focus through the OnClick event of the command
button, then put that last code into the On Lost Focus of the control on the
main form?

Thanks again!
 

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