A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

button question: two different commands?



 
 
Thread Tools Display Modes
  #21  
Old June 1st, 2007, 08:59 AM posted to microsoft.public.access.forms
scubadiver
external usenet poster
 
Posts: 1,673
Default button question: two different commands?


I have sorted out the label change using a text box instead.

Thanks for your help.




"BruceM" wrote:

You do not need two buttons. The code should work. If it doesn't, having
two buttons (or two boxes that look like buttons) is not going to solve
anything.
Comment out the Me.ComQry line of code (remove the breakpoint first), so
that you just have the message box. Click the button. You should see the
message box. If not, go to the Event tab on the button's property sheet,
and verify that you see "Event Procedure" next to the Click event. If you
see it, click the three dots and verify that it takes you to the correct
code. If you do not see it, select Event Procedure for the Click event. If
the code appears, compile and close the VBA window. If there is no code,
that is of course the problem.
Some more things to try:

Try changing your message box line of code to:
MsgBox Me.ComQry.Visible
It should return either True or False

In form design view, there is on the Formatting toolbar a window with a
drop-down arrow. It is the leftmost item on the toolbar by default, I
believe. It lists all of the controls on the form. If ComQry is on the
list, click it and note what is selected on the form.

"scubadiver" wrote in message
...

Thanks for your help.

I will see if I can resolve it but I think I may resort to having two
boxes
and making them look like buttons.



"Baz" wrote:

OK, so the code is running and not throwing an error (is it?). In which
case ComQry, whatever it is, is being made visible/invisible. My hunch
is
that ComQry is not what you think it is.

"scubadiver" wrote in message
...

I inserted the breakpoint at the code and inserted the message
underneath.

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible
MsgBox "Hello World"

End Sub


When I pressed the button the message didn't appear and the first line
turned yellow. I also tried inserting the message before the code

Private Sub CompQryButton_Click()

MsgBox "Hello World"
Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

The message appeared and the second line turned yellow.



"Baz" wrote:

In the code window, click on the line where you want to set the
breakpoint
(the procedure in question only contains one line, so that's where to
set
the breakpoint). On the debug menu, choose "Toggle Breakpoint", and
the
line will go brown.

Run the form and click the button. If the code "runs", it will stop
at
the
breakpoint (the line will turn yellow). If it doesn't stop at the
breakpoint, then the code didn't run, and something is wrong with
your
command button or it's properties.

You can perform a similar test by adding the following line to the
event
procedu

MsgBox "Hello World"

Does the message box appear when you click your button?

"scubadiver" wrote in message
...

compqrybutton is on the main form and comqry does come up in the
list
of
options.

I am not too sure about break points and how I check. I've had a go
but
nothing seems to be happening. Can you clarify? thanks.




"BruceM" wrote:

I doubt Access was confused, but humans may become addled by
similar
names
g.
Just to make sure of a point, the CompQryButton is on the main
form?
Sometimes when code doesn't work, but should, I delete the line
and
type
it
again. Assuming you are using Intellisense in the VBA editor (I
think
that's what it is called when you start typing and get a list of
options),
does ComQry show up among the options after you type "Me."?

"scubadiver" wrote in
message
...

I appreciate that could be a source of difficulty so I have
changed
it.

The button is called "CompQryButton" and the subform control is
called
"comqry". The code I now have in the "on click" event is:

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub








"BruceM" wrote:

Are CompQry and ComQry two different controls? If so, what is
ComQry?

"scubadiver" wrote in
message
...

Private Sub CompQry_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

in the button code on the main form

"Baz" wrote:

Inserted it where?

"scubadiver" wrote
in
message
...

I have inserted the following single line

Me.ComQry.Visible = Not Me.ComQry.Visible

but nothing is happening.



"Baz" wrote:

Private Sub cmdButton_Click()

frmSubform.Visible = Not frmSubform.Visible

End Sub

"scubadiver"
wrote
in
message
...

Is it at all possible to use the same button for two
different
commands. I
want to make a subform visible and invisible with the
same
button.























  #22  
Old June 1st, 2007, 12:08 PM posted to microsoft.public.access.forms
BruceM[_2_]
external usenet poster
 
Posts: 1,763
Default button question: two different commands?

You could have changed the label's Caption property:
Me.LabelName.Caption = "Caption Text"

"scubadiver" wrote in message
news

I have sorted out the label change using a text box instead.

Thanks for your help.




"BruceM" wrote:

You do not need two buttons. The code should work. If it doesn't,
having
two buttons (or two boxes that look like buttons) is not going to solve
anything.
Comment out the Me.ComQry line of code (remove the breakpoint first), so
that you just have the message box. Click the button. You should see
the
message box. If not, go to the Event tab on the button's property sheet,
and verify that you see "Event Procedure" next to the Click event. If
you
see it, click the three dots and verify that it takes you to the correct
code. If you do not see it, select Event Procedure for the Click event.
If
the code appears, compile and close the VBA window. If there is no code,
that is of course the problem.
Some more things to try:

Try changing your message box line of code to:
MsgBox Me.ComQry.Visible
It should return either True or False

In form design view, there is on the Formatting toolbar a window with a
drop-down arrow. It is the leftmost item on the toolbar by default, I
believe. It lists all of the controls on the form. If ComQry is on the
list, click it and note what is selected on the form.

"scubadiver" wrote in message
...

Thanks for your help.

I will see if I can resolve it but I think I may resort to having two
boxes
and making them look like buttons.



"Baz" wrote:

OK, so the code is running and not throwing an error (is it?). In
which
case ComQry, whatever it is, is being made visible/invisible. My
hunch
is
that ComQry is not what you think it is.

"scubadiver" wrote in message
...

I inserted the breakpoint at the code and inserted the message
underneath.

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible
MsgBox "Hello World"

End Sub


When I pressed the button the message didn't appear and the first
line
turned yellow. I also tried inserting the message before the code

Private Sub CompQryButton_Click()

MsgBox "Hello World"
Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

The message appeared and the second line turned yellow.



"Baz" wrote:

In the code window, click on the line where you want to set the
breakpoint
(the procedure in question only contains one line, so that's where
to
set
the breakpoint). On the debug menu, choose "Toggle Breakpoint",
and
the
line will go brown.

Run the form and click the button. If the code "runs", it will
stop
at
the
breakpoint (the line will turn yellow). If it doesn't stop at the
breakpoint, then the code didn't run, and something is wrong with
your
command button or it's properties.

You can perform a similar test by adding the following line to the
event
procedu

MsgBox "Hello World"

Does the message box appear when you click your button?

"scubadiver" wrote in
message
...

compqrybutton is on the main form and comqry does come up in the
list
of
options.

I am not too sure about break points and how I check. I've had a
go
but
nothing seems to be happening. Can you clarify? thanks.




"BruceM" wrote:

I doubt Access was confused, but humans may become addled by
similar
names
g.
Just to make sure of a point, the CompQryButton is on the main
form?
Sometimes when code doesn't work, but should, I delete the
line
and
type
it
again. Assuming you are using Intellisense in the VBA editor
(I
think
that's what it is called when you start typing and get a list
of
options),
does ComQry show up among the options after you type "Me."?

"scubadiver" wrote in
message
...

I appreciate that could be a source of difficulty so I have
changed
it.

The button is called "CompQryButton" and the subform control
is
called
"comqry". The code I now have in the "on click" event is:

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub








"BruceM" wrote:

Are CompQry and ComQry two different controls? If so, what
is
ComQry?

"scubadiver" wrote
in
message
...

Private Sub CompQry_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

in the button code on the main form

"Baz" wrote:

Inserted it where?

"scubadiver"
wrote
in
message
...

I have inserted the following single line

Me.ComQry.Visible = Not Me.ComQry.Visible

but nothing is happening.



"Baz" wrote:

Private Sub cmdButton_Click()

frmSubform.Visible = Not frmSubform.Visible

End Sub

"scubadiver"
wrote
in
message
...

Is it at all possible to use the same button for
two
different
commands. I
want to make a subform visible and invisible with
the
same
button.

























  #23  
Old June 1st, 2007, 12:57 PM posted to microsoft.public.access.forms
scubadiver
external usenet poster
 
Posts: 1,673
Default button question: two different commands?


Ah right!

cheers



"BruceM" wrote:

You could have changed the label's Caption property:
Me.LabelName.Caption = "Caption Text"

"scubadiver" wrote in message
news

I have sorted out the label change using a text box instead.

Thanks for your help.




"BruceM" wrote:

You do not need two buttons. The code should work. If it doesn't,
having
two buttons (or two boxes that look like buttons) is not going to solve
anything.
Comment out the Me.ComQry line of code (remove the breakpoint first), so
that you just have the message box. Click the button. You should see
the
message box. If not, go to the Event tab on the button's property sheet,
and verify that you see "Event Procedure" next to the Click event. If
you
see it, click the three dots and verify that it takes you to the correct
code. If you do not see it, select Event Procedure for the Click event.
If
the code appears, compile and close the VBA window. If there is no code,
that is of course the problem.
Some more things to try:

Try changing your message box line of code to:
MsgBox Me.ComQry.Visible
It should return either True or False

In form design view, there is on the Formatting toolbar a window with a
drop-down arrow. It is the leftmost item on the toolbar by default, I
believe. It lists all of the controls on the form. If ComQry is on the
list, click it and note what is selected on the form.

"scubadiver" wrote in message
...

Thanks for your help.

I will see if I can resolve it but I think I may resort to having two
boxes
and making them look like buttons.



"Baz" wrote:

OK, so the code is running and not throwing an error (is it?). In
which
case ComQry, whatever it is, is being made visible/invisible. My
hunch
is
that ComQry is not what you think it is.

"scubadiver" wrote in message
...

I inserted the breakpoint at the code and inserted the message
underneath.

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible
MsgBox "Hello World"

End Sub


When I pressed the button the message didn't appear and the first
line
turned yellow. I also tried inserting the message before the code

Private Sub CompQryButton_Click()

MsgBox "Hello World"
Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

The message appeared and the second line turned yellow.



"Baz" wrote:

In the code window, click on the line where you want to set the
breakpoint
(the procedure in question only contains one line, so that's where
to
set
the breakpoint). On the debug menu, choose "Toggle Breakpoint",
and
the
line will go brown.

Run the form and click the button. If the code "runs", it will
stop
at
the
breakpoint (the line will turn yellow). If it doesn't stop at the
breakpoint, then the code didn't run, and something is wrong with
your
command button or it's properties.

You can perform a similar test by adding the following line to the
event
procedu

MsgBox "Hello World"

Does the message box appear when you click your button?

"scubadiver" wrote in
message
...

compqrybutton is on the main form and comqry does come up in the
list
of
options.

I am not too sure about break points and how I check. I've had a
go
but
nothing seems to be happening. Can you clarify? thanks.




"BruceM" wrote:

I doubt Access was confused, but humans may become addled by
similar
names
g.
Just to make sure of a point, the CompQryButton is on the main
form?
Sometimes when code doesn't work, but should, I delete the
line
and
type
it
again. Assuming you are using Intellisense in the VBA editor
(I
think
that's what it is called when you start typing and get a list
of
options),
does ComQry show up among the options after you type "Me."?

"scubadiver" wrote in
message
...

I appreciate that could be a source of difficulty so I have
changed
it.

The button is called "CompQryButton" and the subform control
is
called
"comqry". The code I now have in the "on click" event is:

Private Sub CompQryButton_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub








"BruceM" wrote:

Are CompQry and ComQry two different controls? If so, what
is
ComQry?

"scubadiver" wrote
in
message
...

Private Sub CompQry_Click()

Me.ComQry.Visible = Not Me.ComQry.Visible

End Sub

in the button code on the main form

"Baz" wrote:

Inserted it where?

"scubadiver"
wrote
in
message
...

I have inserted the following single line

Me.ComQry.Visible = Not Me.ComQry.Visible

but nothing is happening.



"Baz" wrote:

Private Sub cmdButton_Click()

frmSubform.Visible = Not frmSubform.Visible

End Sub

"scubadiver"
wrote
in
message
...

Is it at all possible to use the same button for
two
different
commands. I
want to make a subform visible and invisible with
the
same
button.


























 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.