Re: coding a command button to change properties on another form



Hello,

I have tried again your suggestion and gone through help but I do not seem
to be getting anywhere. Please see my new syntax below and advise.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Travel Agency Invoice Form", , , , , , "ICameFrom Travel
Agency Note Form"

If OpenArgs = "ICameFrom Travel Agency Note Form" Then
cmdFPer.Enabled = False
cmdPT8.Enabled = False
cmdSw.Enabled = False
Else
'Do nothing
End If
End Sub



"Al Campagna" wrote:

Alylia,
First, that code does not go in the Form1 code. Form1 simply opens Form2.
Try placing your disable code in the Form2 OnOpen event.
OpenArgs string is passed to Form2, so that Form2 can examine and act/notact upon it.

Secondly, the syntax for the FormOpen method is wrong...
I wrote...
DoCmd.OpenForm "frmForm2", , , , , , "ICameFromForm1"

You can leave an optional argument blank in the middle of the syntax, but you must
include the argument's comma. If you leave a trailing argument blank, don't use a comma
following the last argument you specify.
Check Help on the OpenForm syntax...
--
hth
Al Campagna
Candia Computer Consulting
Microsoft Access MVP - Candia, NH USA
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


"Alylia" <Alylia@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:02241FA9-32C5-49E3-B097-F07D4F68B109@xxxxxxxxxxxxxxxx
Thanks for your response but as I had mentioned I had indicated that a
previous response had been helpful which made me to believe that my question
was no longer going to be worked on.

I sincerely regret this misunderstanding and your advice has been fully noted.

I would be grateful if you would review my codes below and tell me where the
problem is becuase it does not work

Private Sub cmdAgInv_Click()
DoCmd.OpenForm "Travel Agency Invoice Form"
If OpenArgs = "Travel Agency Invoice Form" Then
cmdFPer.Enabled = False
cmdPT8.Enabled = False
cmdSw.Enabled = False
Else
'do nothing
End If

End Sub

"Al Campagna" wrote:

Alylia,
Please don't ask the same question again while folks are responding to your first
post.
It creates duplicate effort, and the continuity of the problem will suffer.
If you must re-ask the same question, it would be good to let those folks helping
you
out on the previous post, that you are reposting.
Be patient though, we're all volunteers, and someone who has been helping you may
not
always be available consistently.

Your problem can be handled by the OpenArgs argument of the OpenForm method.
DoCmd.OpenForm "frmForm2", , , , , , "ICameFromForm1"

When Form2 Opens, it can use the OpenArgs value to decide which controls to enable
or
disable.
If OpenArgs = "ICameFromForm1" Then
'disable your controls
Else
'enable your controls
End If

--
hth
Al Campagna
Candia Computer Consulting
Microsoft Access MVP - Candia, NH USA
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

"Alylia" <Alylia@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A2197A9A-C97A-4076-BC00-7074EF5F17FE@xxxxxxxxxxxxxxxx

This question had been posted yesterday but I had in error indicated that an
early response was helpful.

I need help on how to code on one form to chane the property settings of
controls on another form.

I have one command button which has a macro that I use to open the other
form without closing the initial. On this command button that has a macro, I
want to write a code so that when the other form is opened certain command
buttons on it will be disabled.

The form is opened from at least two other forms. What I want is basically
that when I open from this particular form certain command button should be
disabled but when it opened from the other forms these buttons should be
enabled (which is now the case).

There no condition to change the command button properties on the form to be
opened from the intial form. I would like to this form to be opened to view
records only and therefore all command buttons should be disabled except the
one that should close the form.








.