help with Disabled code please

  • Thread starter evilcowstare via AccessMonster.com
  • Start date
E

evilcowstare via AccessMonster.com

Hello All !

Was just wondering if someone can help me with a little code. I know bits of
what I want to do but getting a bit confused...

Basically I have two forms, on one form is a button that opens up the second
form using...

On_Click

DoCmd.OpenForm "Jobs", , , , acFormAdd

what I would also like it to do is from that button only that when the second
form opens certain buttons and combos are disabled. I want this to only
happen from the button and not if the 2nd form is opened on its own without
the 1st form.

Im guessing that I need to add additional code to the on click part but Im
unsure what to put.

The first Form with the button is called Customers, the second form in called
Jobs.

The only code ive used for this sort of thing has been in the same form that
the stuff I have been trying to disable has been on, Ive never tried to make
it do it via another form
If it helps the code I have used before which was designed to make a button
disabled until the combo had something selected was...

sitebutton.Enabled = Not IsNull (addresscombo)

If anyone can help it will be appreciated, Im sure that the answer is a lot
easier then all this stuff ive just waffled on about :eek:)

Thank You !
 
M

Maurice

You could try something like this:

after your code from form 1: DoCmd.OpenForm "Jobs", , , , acFormAdd

forms!form2!control.enabled=false

Where form2=name of your second form
Where control=name of the control you want to be disabled.

If you choose this method you can still open form 2 without disabeling
anything if you open the form by itself.

Maurice
 
E

evilcowstare via AccessMonster.com

Fab!!!
Thank You very much works great.
Just a quick Q, so if you need to locate something from another form or table
do you just always use ! to separate the location parts so it will always be..
..

forms!formname!name of item in form
or
tables!tablename! name of field in table

Ive only ever used dots .. which is what you use for in the same form right?

Like Me.nameofcontrol

could you also do
forms.formname.control from outside
or
Me!nameofcontrol

Or is is just for either
Thank You loads !!!!

You could try something like this:

after your code from form 1: DoCmd.OpenForm "Jobs", , , , acFormAdd

forms!form2!control.enabled=false

Where form2=name of your second form
Where control=name of the control you want to be disabled.

If you choose this method you can still open form 2 without disabeling
anything if you open the form by itself.

Maurice
Hello All !
[quoted text clipped - 31 lines]
Thank You !
 
M

Maurice

I always use the (bang) ! to seperate and use the (dot) . to reference the
properties. So as a rule of thumb use ! for referencing objects you've
created like reports forms etc and use the . for methods and props like
"visible", "enabled" etc.

Good to hear it worked for you. Keep up the good work!

Maurice

evilcowstare via AccessMonster.com said:
Fab!!!
Thank You very much works great.
Just a quick Q, so if you need to locate something from another form or table
do you just always use ! to separate the location parts so it will always be..
..

forms!formname!name of item in form
or
tables!tablename! name of field in table

Ive only ever used dots .. which is what you use for in the same form right?

Like Me.nameofcontrol

could you also do
forms.formname.control from outside
or
Me!nameofcontrol

Or is is just for either
Thank You loads !!!!

You could try something like this:

after your code from form 1: DoCmd.OpenForm "Jobs", , , , acFormAdd

forms!form2!control.enabled=false

Where form2=name of your second form
Where control=name of the control you want to be disabled.

If you choose this method you can still open form 2 without disabeling
anything if you open the form by itself.

Maurice
Hello All !
[quoted text clipped - 31 lines]
Thank You !
 

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