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  

Disable/Enable Command Button



 
 
Thread Tools Display Modes
  #1  
Old December 24th, 2006, 05:07 PM posted to microsoft.public.access.forms
mdavis via AccessMonster.com
external usenet poster
 
Posts: 15
Default Disable/Enable Command Button

Form A has an unbound list box based on a query. When the list box has a
record in it I want a command button called ADD to be disabled and a command
button called EDIT to be enabled.

When their isn't a record in the list box I would like the ADD command button
to be enabled and the EDIT command button to be disabled.

Also know that the ADD and EDIT command buttons open up pop forms that will
allow the user to either add or edit records.

When Form A is closed and reopened I would like the ADD and EDIT command
buttons to be enabled or disabled based on the value of the list box.

Thank you in advance.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #2  
Old December 24th, 2006, 05:17 PM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Disable/Enable Command Button

mdavis via AccessMonster.com wrote:
Form A has an unbound list box based on a query. When the list box
has a record in it I want a command button called ADD to be disabled
and a command button called EDIT to be enabled.

When their isn't a record in the list box I would like the ADD
command button to be enabled and the EDIT command button to be
disabled.

Also know that the ADD and EDIT command buttons open up pop forms
that will allow the user to either add or edit records.

When Form A is closed and reopened I would like the ADD and EDIT
command buttons to be enabled or disabled based on the value of the
list box.

Thank you in advance.


Might I suggest a single button with a caption of Add/Edit and a single form
that does both functions? All you have to do is filter on the entry in the
ListBox when opening a single form to accomplish both adding and editing.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #3  
Old December 24th, 2006, 05:57 PM posted to microsoft.public.access.forms
mdavis via AccessMonster.com
external usenet poster
 
Posts: 15
Default Disable/Enable Command Button

Could you give me an example of the code I would use to accomplish this?

Rick Brandt wrote:
Form A has an unbound list box based on a query. When the list box
has a record in it I want a command button called ADD to be disabled

[quoted text clipped - 12 lines]

Thank you in advance.


Might I suggest a single button with a caption of Add/Edit and a single form
that does both functions? All you have to do is filter on the entry in the
ListBox when opening a single form to accomplish both adding and editing.


--
Message posted via http://www.accessmonster.com

  #4  
Old December 24th, 2006, 06:10 PM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Disable/Enable Command Button

mdavis via AccessMonster.com wrote:
Could you give me an example of the code I would use to accomplish
this?


Use the command button wizard in design view of the form with the ListBox. The
wizard options would be...

Form Operations - Open Form
Name Of the Add/Edit form
Open The form and find specific data to display
ListBoxName - FieldName

That will construct code for the button that uses the DoCmd.OpenForm method with
a supplied WHERE aregument that will pre-filter the form being opened to match
the value currently selected in the ListBox. When no matching record exists
(like when the ListBox is empty) then the form will be opened to the blank
NewRecord position ready to add a new record.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 




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 08:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.