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  

Activating a Command Button on a Form



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2010, 09:20 PM posted to microsoft.public.access.forms
SLEJ
external usenet poster
 
Posts: 7
Default Activating a Command Button on a Form

SITUATION
I have an Orders Form with two command buttons: Pull Sheet & Packing Slip.
The form also has fields for the user to enter Order Date, Entered Date, and
Picked Date.

What I would like to do is, if all three date fields have dates in them,
then both command buttons are active; if certain combinations of the fields
are completed or not, then either one, both, or neither button is selectable.

I put the code below in the ON CURRENT for the form. This works well BUT,
it doesn't take effect until the user exists the current record then goes
back to it. For example, if a new order comes in and the Order Date and the
Entered Date are completed, the Pull Sheet button isn't selectable until that
record is left and then returned to.

Private Sub Form_Current()
If (Me.receivedate) = #1/1/1900# And (Me.enterdate) = #1/1/1900#
And (Me.pickdate) = #1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = True
ElseIf (Me.receivedate) = #1/1/1900# And (Me.enterdate) =
#1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = False
Else
Me.btnPullSheet.Enabled = False
Me.btnPackingSlip.Enabled = False
End If
End Sub

QUESTION
Is there a way to code the form or the buttons or the date controls so that
the command buttons will immediately either become active or disabled without
having to exit the record? Thanks.
--
Sharon
  #2  
Old January 14th, 2010, 11:35 PM posted to microsoft.public.access.forms
Rob Parker[_3_]
external usenet poster
 
Posts: 173
Default Activating a Command Button on a Form

You need to put this same code in the AfterUpdate event of each of the date
controls. Or, perhaps easier, call the Form_Current code in the AfterUpdate
events.

I'd also suggest that you use Not IsNull (Me.datefield), rather than
checking that the date is later than 1/1/1900.

HTH,

Rob


Slej wrote:
SITUATION
I have an Orders Form with two command buttons: Pull Sheet & Packing
Slip. The form also has fields for the user to enter Order Date,
Entered Date, and Picked Date.

What I would like to do is, if all three date fields have dates in
them, then both command buttons are active; if certain combinations
of the fields are completed or not, then either one, both, or neither
button is selectable.

I put the code below in the ON CURRENT for the form. This works well
BUT, it doesn't take effect until the user exists the current record
then goes back to it. For example, if a new order comes in and the
Order Date and the Entered Date are completed, the Pull Sheet button
isn't selectable until that record is left and then returned to.

Private Sub Form_Current()
If (Me.receivedate) = #1/1/1900# And (Me.enterdate) =
#1/1/1900# And (Me.pickdate) = #1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = True
ElseIf (Me.receivedate) = #1/1/1900# And (Me.enterdate) =
#1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = False
Else
Me.btnPullSheet.Enabled = False
Me.btnPackingSlip.Enabled = False
End If
End Sub

QUESTION
Is there a way to code the form or the buttons or the date controls
so that the command buttons will immediately either become active or
disabled without having to exit the record? Thanks.



  #3  
Old January 15th, 2010, 02:32 PM posted to microsoft.public.access.forms
SLEJ
external usenet poster
 
Posts: 7
Default Activating a Command Button on a Form

Rob,

You are my new best friend! This worked perfectly. Thanks.
--
Sharon


"Rob Parker" wrote:

You need to put this same code in the AfterUpdate event of each of the date
controls. Or, perhaps easier, call the Form_Current code in the AfterUpdate
events.

I'd also suggest that you use Not IsNull (Me.datefield), rather than
checking that the date is later than 1/1/1900.

HTH,

Rob


Slej wrote:
SITUATION
I have an Orders Form with two command buttons: Pull Sheet & Packing
Slip. The form also has fields for the user to enter Order Date,
Entered Date, and Picked Date.

What I would like to do is, if all three date fields have dates in
them, then both command buttons are active; if certain combinations
of the fields are completed or not, then either one, both, or neither
button is selectable.

I put the code below in the ON CURRENT for the form. This works well
BUT, it doesn't take effect until the user exists the current record
then goes back to it. For example, if a new order comes in and the
Order Date and the Entered Date are completed, the Pull Sheet button
isn't selectable until that record is left and then returned to.

Private Sub Form_Current()
If (Me.receivedate) = #1/1/1900# And (Me.enterdate) =
#1/1/1900# And (Me.pickdate) = #1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = True
ElseIf (Me.receivedate) = #1/1/1900# And (Me.enterdate) =
#1/1/1900# Then
Me.btnPullSheet.Enabled = True
Me.btnPackingSlip.Enabled = False
Else
Me.btnPullSheet.Enabled = False
Me.btnPackingSlip.Enabled = False
End If
End Sub

QUESTION
Is there a way to code the form or the buttons or the date controls
so that the command buttons will immediately either become active or
disabled without having to exit the record? Thanks.



.

 




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 01:50 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.