Unhide control on another form

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I have a command button on a form (frmFirst) that opens
another form (frmSecond). frmSecond can be opened from
several places in the database. I want a control on
frmSecond to be visible only when frmSecond is opened from
frmFirst. A command button on frmFirst has as its On
Click event:
DoCmd.OpenForm "frmSecond", , , , , acDialog

I had hoped that another line of code:
Forms![frmSecond]![cmdMyControl].Visible = True

would make cmdMyControl visible on frmSecond (its visible
property is set to No on the property sheet). However, it
does not work. Could somebody tell me what I am doing
wrong?
 
By using acDialog in the DoCmd.OpenForm statement, you have
opened the form as a modal and, as such, execution stops in
frmFirst. Try setting a value in the OpenArgs parameter
then testing OpenArgs in frmSeconds Load eventhandler to
determine whether the formwas opened by frmFirst and set
the visible property of the command button accordingly.

Hope This Helps
Gerald STanley MCSD
 
OK, I didn't follow much of that. I am becoming more
familiar with VBA, but some of what I use is copied from
somewhere or other. That acDialog bit was one of those
things. However, I understood some of it, I think. I
removed the commas and the acDialog, and it worked in
terms of making the control visible. In the meantime,
though, I decided that I just needed a Close command
button on the form. I realize that I need to learn more
about those commas and all of the stuff that can go in
between them. Thanks for taking the time to answer my
question. If you get a chance to look at the explanation
below, perhaps you could tell me if the approach is sound,
or if I am setting myself up for problems.
The way it works with my database is that I have several
reports that are meant to be printed and faxed. Each
report has as its On Open event:
DoCmd.OpenForm "frmFaxInfo", , , , , acDialog
(I got the code from a newsgroup, I think). frmFaxInfo
contains a combination box for the name of the person
sending the fax, and a few things of the sort. A command
button on the form sets the form's visible property to
False. This puts the fax (report) on top, with the
sender's name, etc. in text boxes that have the controls
on frmFaxInfo as their control sources. The On Close
event for the fax is to close frmFaxInfo. This seems to
work better than using the form to open the report, in
that any number of faxes (reports) can use the same form
to enter the sender's name, etc.
The other thing I have going is that frmFaxInfo contains a
command button that opens frmNameAndTitle, where a user
can add or edit a name and title for the list on
frmFaxInfo. Once the name and title are added, a command
button on frmNameAndTitle saves the record and closes the
form, leaving frmFaxInfo on top. The user can then select
the new name from the combo box list. Clicking the View
Fax command button hides frmFaxInfo as described above.
-----Original Message-----
By using acDialog in the DoCmd.OpenForm statement, you have
opened the form as a modal and, as such, execution stops in
frmFirst. Try setting a value in the OpenArgs parameter
then testing OpenArgs in frmSeconds Load eventhandler to
determine whether the formwas opened by frmFirst and set
the visible property of the command button accordingly.

Hope This Helps
Gerald STanley MCSD
-----Original Message-----
I have a command button on a form (frmFirst) that opens
another form (frmSecond). frmSecond can be opened from
several places in the database. I want a control on
frmSecond to be visible only when frmSecond is opened from
frmFirst. A command button on frmFirst has as its On
Click event:
DoCmd.OpenForm "frmSecond", , , , , acDialog

I had hoped that another line of code:
Forms![frmSecond]![cmdMyControl].Visible = True

would make cmdMyControl visible on frmSecond (its visible
property is set to No on the property sheet). However, it
does not work. Could somebody tell me what I am doing
wrong?
.
.
 
Bruce

The outline looks pretty sound to me.

Gerald Stanley MCSD
-----Original Message-----
OK, I didn't follow much of that. I am becoming more
familiar with VBA, but some of what I use is copied from
somewhere or other. That acDialog bit was one of those
things. However, I understood some of it, I think. I
removed the commas and the acDialog, and it worked in
terms of making the control visible. In the meantime,
though, I decided that I just needed a Close command
button on the form. I realize that I need to learn more
about those commas and all of the stuff that can go in
between them. Thanks for taking the time to answer my
question. If you get a chance to look at the explanation
below, perhaps you could tell me if the approach is sound,
or if I am setting myself up for problems.
The way it works with my database is that I have several
reports that are meant to be printed and faxed. Each
report has as its On Open event:
DoCmd.OpenForm "frmFaxInfo", , , , , acDialog
(I got the code from a newsgroup, I think). frmFaxInfo
contains a combination box for the name of the person
sending the fax, and a few things of the sort. A command
button on the form sets the form's visible property to
False. This puts the fax (report) on top, with the
sender's name, etc. in text boxes that have the controls
on frmFaxInfo as their control sources. The On Close
event for the fax is to close frmFaxInfo. This seems to
work better than using the form to open the report, in
that any number of faxes (reports) can use the same form
to enter the sender's name, etc.
The other thing I have going is that frmFaxInfo contains a
command button that opens frmNameAndTitle, where a user
can add or edit a name and title for the list on
frmFaxInfo. Once the name and title are added, a command
button on frmNameAndTitle saves the record and closes the
form, leaving frmFaxInfo on top. The user can then select
the new name from the combo box list. Clicking the View
Fax command button hides frmFaxInfo as described above.
-----Original Message-----
By using acDialog in the DoCmd.OpenForm statement, you have
opened the form as a modal and, as such, execution stops in
frmFirst. Try setting a value in the OpenArgs parameter
then testing OpenArgs in frmSeconds Load eventhandler to
determine whether the formwas opened by frmFirst and set
the visible property of the command button accordingly.

Hope This Helps
Gerald STanley MCSD
-----Original Message-----
I have a command button on a form (frmFirst) that opens
another form (frmSecond). frmSecond can be opened from
several places in the database. I want a control on
frmSecond to be visible only when frmSecond is opened from
frmFirst. A command button on frmFirst has as its On
Click event:
DoCmd.OpenForm "frmSecond", , , , , acDialog

I had hoped that another line of code:
Forms![frmSecond]![cmdMyControl].Visible = True

would make cmdMyControl visible on frmSecond (its visible
property is set to No on the property sheet). However, it
does not work. Could somebody tell me what I am doing
wrong?
.
.
.
 
Thanks again.
-----Original Message-----
Bruce

The outline looks pretty sound to me.

Gerald Stanley MCSD
-----Original Message-----
OK, I didn't follow much of that. I am becoming more
familiar with VBA, but some of what I use is copied from
somewhere or other. That acDialog bit was one of those
things. However, I understood some of it, I think. I
removed the commas and the acDialog, and it worked in
terms of making the control visible. In the meantime,
though, I decided that I just needed a Close command
button on the form. I realize that I need to learn more
about those commas and all of the stuff that can go in
between them. Thanks for taking the time to answer my
question. If you get a chance to look at the explanation
below, perhaps you could tell me if the approach is sound,
or if I am setting myself up for problems.
The way it works with my database is that I have several
reports that are meant to be printed and faxed. Each
report has as its On Open event:
DoCmd.OpenForm "frmFaxInfo", , , , , acDialog
(I got the code from a newsgroup, I think). frmFaxInfo
contains a combination box for the name of the person
sending the fax, and a few things of the sort. A command
button on the form sets the form's visible property to
False. This puts the fax (report) on top, with the
sender's name, etc. in text boxes that have the controls
on frmFaxInfo as their control sources. The On Close
event for the fax is to close frmFaxInfo. This seems to
work better than using the form to open the report, in
that any number of faxes (reports) can use the same form
to enter the sender's name, etc.
The other thing I have going is that frmFaxInfo contains a
command button that opens frmNameAndTitle, where a user
can add or edit a name and title for the list on
frmFaxInfo. Once the name and title are added, a command
button on frmNameAndTitle saves the record and closes the
form, leaving frmFaxInfo on top. The user can then select
the new name from the combo box list. Clicking the View
Fax command button hides frmFaxInfo as described above.
-----Original Message-----
By using acDialog in the DoCmd.OpenForm statement, you have
opened the form as a modal and, as such, execution
stops
in
frmFirst. Try setting a value in the OpenArgs parameter
then testing OpenArgs in frmSeconds Load eventhandler to
determine whether the formwas opened by frmFirst and set
the visible property of the command button accordingly.

Hope This Helps
Gerald STanley MCSD
-----Original Message-----
I have a command button on a form (frmFirst) that opens
another form (frmSecond). frmSecond can be opened from
several places in the database. I want a control on
frmSecond to be visible only when frmSecond is opened from
frmFirst. A command button on frmFirst has as its On
Click event:
DoCmd.OpenForm "frmSecond", , , , , acDialog

I had hoped that another line of code:
Forms![frmSecond]![cmdMyControl].Visible = True

would make cmdMyControl visible on frmSecond (its visible
property is set to No on the property sheet).
However,
it
does not work. Could somebody tell me what I am doing
wrong?
.

.
.
.
 
Back
Top