button - disable? warning message?

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

evilcowstare via AccessMonster.com

Hello
I have a button on a form that runs a macro to open up another form to
display details against a selection that was made in the 1st form.
For example Main form1 had a drop down, next to it is a button.
when the button is clicked it runs a macro to open form 2 with details
related to the drop downs selection.
This all works fine when it has a selection in it, the problem I have is if
the button is pressed before the selection is made it brings up form2 as a
grey square and you can do nothing to it, is there anyway i can make it so
that the button either wont work until a selection is made in the drop down
or it brings up a message to make a selection first and doesnt run the macro?


Thank You :eek:)
 
A

Al Campagna

evil,
Given [cmdOpen2] to open the report, and using the AfterUpdate event of your combo
[cboSelection]...
(use your own object names)

Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

Also, using the OnCurrent event of the form... (the same code)
Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

As you browse from record to record, if cboSelectioon is null, cmdOpen2 is Disabled.
If you delete the selection in cboSelection, cmdOpen2 goes Disabled
Only if cboSelection has a value will cmdOpen2 Enable.

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

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

evilcowstare via AccessMonster.com

Hi Al thanks for the reply, I cant get it to work but think its probably my
fault.
My macro which opens the report is called operativelookup
The combo is called operativecombo
The button is called operative button
and I am putting the code into the AfterUpdate bit of the combo properties.

This is how it reads..

Private Sub operativecombo_AfterUpdate()
Private Sub operativebutton_Click()
operativecombo = Not IsNull(operativecombo)
End Sub

Im guessing I changed it wrongly, could you correct what Ive done wrong if
poss.

Thank You

Al said:
evil,
Given [cmdOpen2] to open the report, and using the AfterUpdate event of your combo
[cboSelection]...
(use your own object names)

Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

Also, using the OnCurrent event of the form... (the same code)
Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

As you browse from record to record, if cboSelectioon is null, cmdOpen2 is Disabled.
If you delete the selection in cboSelection, cmdOpen2 goes Disabled
Only if cboSelection has a value will cmdOpen2 Enable.
Hello
I have a button on a form that runs a macro to open up another form to
[quoted text clipped - 9 lines]
Thank You :eek:)
 
A

Al Campagna

I can see where I made a typo... such are the problems of doing code in emails...

My code only controls wether the OperativeButton is Enabled/Disbaled according to the
value in OperativeCombo. If OperativeCombo is Null, the button to print the report is
Disabled. If OperativeCombo is Not Null, the OperativeButton is enabled, and clicking it
will run the report.
Again, make sure you use YOUR object names in the code... and each of these pieces of
code has to be installed in the objects proper event.

Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
----------------------------------------
Private Sub UseYourFormNameHere_Current()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
-----------------------------------------
Private Sub OperativeButton_Click()
DoCmd.OpenReport "OperativeLookup"
End Sub

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

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


evilcowstare via AccessMonster.com said:
Hi Al thanks for the reply, I cant get it to work but think its probably my
fault.
My macro which opens the report is called operativelookup
The combo is called operativecombo
The button is called operative button
and I am putting the code into the AfterUpdate bit of the combo properties.

This is how it reads..

Private Sub operativecombo_AfterUpdate()
Private Sub operativebutton_Click()
operativecombo = Not IsNull(operativecombo)
End Sub

Im guessing I changed it wrongly, could you correct what Ive done wrong if
poss.

Thank You

Al said:
evil,
Given [cmdOpen2] to open the report, and using the AfterUpdate event of your combo
[cboSelection]...
(use your own object names)

Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

Also, using the OnCurrent event of the form... (the same code)
Private Sub cmdOpen2_Click()
cmdOpen2.Enabled = Not IsNull(cboSelection)
End Sub

As you browse from record to record, if cboSelectioon is null, cmdOpen2 is Disabled.
If you delete the selection in cboSelection, cmdOpen2 goes Disabled
Only if cboSelection has a value will cmdOpen2 Enable.
Hello
I have a button on a form that runs a macro to open up another form to
[quoted text clipped - 9 lines]
Thank You :eek:)
 
E

evilcowstare via AccessMonster.com

Hi thanks for coming back, im probably being a complete spanner but where
should I put each of the 3 codes?
Sorry im a bit of a novice and the places I have tried come back with errors

Thank You
Jay

Al said:
I can see where I made a typo... such are the problems of doing code in emails...

My code only controls wether the OperativeButton is Enabled/Disbaled according to the
value in OperativeCombo. If OperativeCombo is Null, the button to print the report is
Disabled. If OperativeCombo is Not Null, the OperativeButton is enabled, and clicking it
will run the report.
Again, make sure you use YOUR object names in the code... and each of these pieces of
code has to be installed in the objects proper event.

Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
----------------------------------------
Private Sub UseYourFormNameHere_Current()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
-----------------------------------------
Private Sub OperativeButton_Click()
DoCmd.OpenReport "OperativeLookup"
End Sub
Hi Al thanks for the reply, I cant get it to work but think its probably my
fault.
[quoted text clipped - 38 lines]
 
A

Al Campagna

First, go to OpoerativeCombo in design mode. In the Properties box you'll see an
AfterUpdate event.
Place your cursor in the text associatedbox.
Select Event Procedure from the drop down arrow on the right of the text box.
Select the button with 3 dots (...) on the right.
You'll see this...
Private Sub OperativeCombo_AfterUpdate()

End Sub

Now, make it look like the code I suggested for that event...
Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub

Do the same procedure for the other two events Form OnCurrent and OperativeButton
OnClick... using my code examples for each.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

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

evilcowstare via AccessMonster.com said:
Hi thanks for coming back, im probably being a complete spanner but where
should I put each of the 3 codes?
Sorry im a bit of a novice and the places I have tried come back with errors

Thank You
Jay

Al said:
I can see where I made a typo... such are the problems of doing code in emails...

My code only controls wether the OperativeButton is Enabled/Disbaled according to the
value in OperativeCombo. If OperativeCombo is Null, the button to print the report is
Disabled. If OperativeCombo is Not Null, the OperativeButton is enabled, and clicking
it
will run the report.
Again, make sure you use YOUR object names in the code... and each of these pieces of
code has to be installed in the objects proper event.

Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
----------------------------------------
Private Sub UseYourFormNameHere_Current()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub
-----------------------------------------
Private Sub OperativeButton_Click()
DoCmd.OpenReport "OperativeLookup"
End Sub
Hi Al thanks for the reply, I cant get it to work but think its probably my
fault.
[quoted text clipped - 38 lines]
Thank You :eek:)
 
E

evilcowstare via AccessMonster.com

Hi Al, really appreciate you coming back to help.
Ive entered all the stuff in the right places, have no error messages but its
not making the button disabled when there is nothing in the combo box, im
still getting a blank grey form?



Al said:
First, go to OpoerativeCombo in design mode. In the Properties box you'll see an
AfterUpdate event.
Place your cursor in the text associatedbox.
Select Event Procedure from the drop down arrow on the right of the text box.
Select the button with 3 dots (...) on the right.
You'll see this...
Private Sub OperativeCombo_AfterUpdate()

End Sub

Now, make it look like the code I suggested for that event...
Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub

Do the same procedure for the other two events Form OnCurrent and OperativeButton
OnClick... using my code examples for each.
Hi thanks for coming back, im probably being a complete spanner but where
should I put each of the 3 codes?
[quoted text clipped - 30 lines]
 
A

Al Campagna

evil,
Zip and send me your mdb file via my website below. In the post, explain exactly what
form, and where the problem is.
*** Use the term "newsgroup" in the subject of the email **
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

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

evilcowstare via AccessMonster.com said:
Hi Al, really appreciate you coming back to help.
Ive entered all the stuff in the right places, have no error messages but its
not making the button disabled when there is nothing in the combo box, im
still getting a blank grey form?



Al said:
First, go to OpoerativeCombo in design mode. In the Properties box you'll see an
AfterUpdate event.
Place your cursor in the text associatedbox.
Select Event Procedure from the drop down arrow on the right of the text box.
Select the button with 3 dots (...) on the right.
You'll see this...
Private Sub OperativeCombo_AfterUpdate()

End Sub

Now, make it look like the code I suggested for that event...
Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub

Do the same procedure for the other two events Form OnCurrent and OperativeButton
OnClick... using my code examples for each.
Hi thanks for coming back, im probably being a complete spanner but where
should I put each of the 3 codes?
[quoted text clipped - 30 lines]
Thank You :eek:)
 
E

evilcowstare via AccessMonster.com

Hi Al thanks, have done :eek:)

Al said:
evil,
Zip and send me your mdb file via my website below. In the post, explain exactly what
form, and where the problem is.
*** Use the term "newsgroup" in the subject of the email **
Hi Al, really appreciate you coming back to help.
Ive entered all the stuff in the right places, have no error messages but its
[quoted text clipped - 23 lines]
 
A

Al Campagna

The solution was a Refresh in the combo AfterUpdate...
--
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

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

Al Campagna said:
evil,
Zip and send me your mdb file via my website below. In the post, explain exactly what
form, and where the problem is.
*** Use the term "newsgroup" in the subject of the email **
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

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

evilcowstare via AccessMonster.com said:
Hi Al, really appreciate you coming back to help.
Ive entered all the stuff in the right places, have no error messages but its
not making the button disabled when there is nothing in the combo box, im
still getting a blank grey form?



Al said:
First, go to OpoerativeCombo in design mode. In the Properties box you'll see an
AfterUpdate event.
Place your cursor in the text associatedbox.
Select Event Procedure from the drop down arrow on the right of the text box.
Select the button with 3 dots (...) on the right.
You'll see this...
Private Sub OperativeCombo_AfterUpdate()

End Sub

Now, make it look like the code I suggested for that event...
Private Sub OperativeCombo_AfterUpdate()
OperativeButton.Enabled = Not IsNull(OperativeCombo)
End Sub

Do the same procedure for the other two events Form OnCurrent and OperativeButton
OnClick... using my code examples for each.
Hi thanks for coming back, im probably being a complete spanner but where
should I put each of the 3 codes?
[quoted text clipped - 30 lines]

Thank You :eek:)
 
Top