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  

Make a command button conditionally unavailable



 
 
Thread Tools Display Modes
  #1  
Old December 22nd, 2005, 01:03 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Hi all,

I have two simple command buttons that navigate back-n-forth between
available records. How can modify the forward button so that if there is
only one record, the button grays out can not be used? Right now, it is
always available, even though there isn't always a second record.

As a heads up, I'm OK with access, but not with coding. If the answer
involves such, please tell me exactly what to do with the code provided.

Thanks!
Joe
  #2  
Old December 22nd, 2005, 02:52 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

The easiest answer to this is to use the built-in buttons. However, it can
be done in code. You would check the current record number against the
record count of the form. If they match, you're at the last record. This
could be done in the form's Current event.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
news
Hi all,

I have two simple command buttons that navigate back-n-forth between
available records. How can modify the forward button so that if there is
only one record, the button grays out can not be used? Right now, it is
always available, even though there isn't always a second record.

As a heads up, I'm OK with access, but not with coding. If the answer
involves such, please tell me exactly what to do with the code provided.

Thanks!
Joe


  #3  
Old December 22nd, 2005, 03:35 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Wayne,

This does make a difference. The next button IS disabled. Only problem is
that it seems to be 'permanently' disabled. Even if this subform has more
than one record available, the button does not become available. Any ideas?

Thanks for your help so far. I'm very excited to see my goal almost reached!
Joe

"Wayne Morgan" wrote:

The easiest answer to this is to use the built-in buttons. However, it can
be done in code. You would check the current record number against the
record count of the form. If they match, you're at the last record. This
could be done in the form's Current event.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
news
Hi all,

I have two simple command buttons that navigate back-n-forth between
available records. How can modify the forward button so that if there is
only one record, the button grays out can not be used? Right now, it is
always available, even though there isn't always a second record.

As a heads up, I'm OK with access, but not with coding. If the answer
involves such, please tell me exactly what to do with the code provided.

Thanks!
Joe




  #4  
Old December 22nd, 2005, 04:03 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Joe,

The code I listed, if placed in the form's Current event, won't care what
the default setting of the button is (enabled or disabled). Instead the code
will set it as needed for the current position in the form's record set. You
may need to make an exception also for no records (i.e. RecordCount = 0).

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
...
Wayne,

This does make a difference. The next button IS disabled. Only problem
is
that it seems to be 'permanently' disabled. Even if this subform has more
than one record available, the button does not become available. Any
ideas?

Thanks for your help so far. I'm very excited to see my goal almost
reached!
Joe

"Wayne Morgan" wrote:

The easiest answer to this is to use the built-in buttons. However, it
can
be done in code. You would check the current record number against the
record count of the form. If they match, you're at the last record. This
could be done in the form's Current event.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
news
Hi all,

I have two simple command buttons that navigate back-n-forth between
available records. How can modify the forward button so that if there
is
only one record, the button grays out can not be used? Right now, it
is
always available, even though there isn't always a second record.

As a heads up, I'm OK with access, but not with coding. If the answer
involves such, please tell me exactly what to do with the code
provided.

Thanks!
Joe






  #5  
Old December 22nd, 2005, 01:09 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Wayne,

Forgive me...I'm just a little confused by your response. What exactly does
the code you provided for me do? It is supposed to enable the next button if
the record count is more than one? If so, what am I missing? So far, the
button continues to remain disabled 100% of the time.

And how would the exception you listed look like in the code you provided?

Thanks again for you help. I truly appreciate it.,
Joe

"Wayne Morgan" wrote:

Joe,

The code I listed, if placed in the form's Current event, won't care what
the default setting of the button is (enabled or disabled). Instead the code
will set it as needed for the current position in the form's record set. You
may need to make an exception also for no records (i.e. RecordCount = 0).

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
...
Wayne,

This does make a difference. The next button IS disabled. Only problem
is
that it seems to be 'permanently' disabled. Even if this subform has more
than one record available, the button does not become available. Any
ideas?

Thanks for your help so far. I'm very excited to see my goal almost
reached!
Joe

"Wayne Morgan" wrote:

The easiest answer to this is to use the built-in buttons. However, it
can
be done in code. You would check the current record number against the
record count of the form. If they match, you're at the last record. This
could be done in the form's Current event.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
news Hi all,

I have two simple command buttons that navigate back-n-forth between
available records. How can modify the forward button so that if there
is
only one record, the button grays out can not be used? Right now, it
is
always available, even though there isn't always a second record.

As a heads up, I'm OK with access, but not with coding. If the answer
involves such, please tell me exactly what to do with the code
provided.

Thanks!
Joe






  #6  
Old December 22nd, 2005, 01:26 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Yes, it should enable the button if there is one or more records remaining.
Where have you placed the code? Did you adjust the name that I used for the
actual name of your button? You now mention a subform, where has this code
been placed in relation to the subform? Where is the button located in
relation to the subform?

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
...
Wayne,

Forgive me...I'm just a little confused by your response. What exactly
does
the code you provided for me do? It is supposed to enable the next button
if
the record count is more than one? If so, what am I missing? So far, the
button continues to remain disabled 100% of the time.

And how would the exception you listed look like in the code you provided?



  #7  
Old December 22nd, 2005, 01:48 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

To check for no records or at a new record, just ammend the IF part of the
statement. This will get a little long, the first line should be all on one
line. The newsreader will proabably wrap it due to its length.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Or
Me.Recordset.RecordCount = 0 Or Me.NewRecord Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If



--
Wayne Morgan
MS Access MVP


  #8  
Old December 22nd, 2005, 06:12 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Thanks for the new code. I will update accordingly.

Yes - the code has been placed into the subform properties (double-clicked
the small gray box in upper left corner of form). It was placed in the 'On
Current' line as an 'Event procedure'. The button names in the code you
provided have been changed to work with the names I gave them. The buttons
themselves appear in the detail section of the subform. The entire subform
has then been placed into the detail section of the main form.

Hope this helps,
Joe

"Wayne Morgan" wrote:

Yes, it should enable the button if there is one or more records remaining.
Where have you placed the code? Did you adjust the name that I used for the
actual name of your button? You now mention a subform, where has this code
been placed in relation to the subform? Where is the button located in
relation to the subform?

--
Wayne Morgan
MS Access MVP


"Access Joe" wrote in message
...
Wayne,

Forgive me...I'm just a little confused by your response. What exactly
does
the code you provided for me do? It is supposed to enable the next button
if
the record count is more than one? If so, what am I missing? So far, the
button continues to remain disabled 100% of the time.

And how would the exception you listed look like in the code you provided?




  #9  
Old December 22nd, 2005, 09:48 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Make a command button conditionally unavailable

Friend,

joel-ange sitbon has invited you to join GreenZap and get $50 WebCash to
spend online. Sign up for a FREE GreenZap account and get $50 to spend at
hundreds of the world's premier merchants, many of whom are offering
incredible upfront discounts. Click on the link below to go to GreenZap and
signup! All thanks to joel-ange sitbon.

It's Zappening in the GreenZap Storez.
http://www.greenzap.com/joel1962

If you do not want to receive these emails in the future click the link
below:
http://www.greenzap.com/optout_invite.asp


"Wayne Morgan" wrote in message
...
To check for no records or at a new record, just ammend the IF part of the
statement. This will get a little long, the first line should be all on
one line. The newsreader will proabably wrap it due to its length.

If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Or
Me.Recordset.RecordCount = 0 Or Me.NewRecord Then
Me.cmdNextButton.Enabled = False
Else
Me.cmdNextButton.Enabled = True
End If



--
Wayne Morgan
MS Access MVP



 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
best program to make animated gif for powerpoint??? LisaH Powerpoint 7 October 9th, 2005 11:50 AM
make controls unavailable in powerpoint presentation radar Powerpoint 1 August 30th, 2005 01:40 AM
MAKE QUICK CASH RIGHT NOW!!! 100% LEGAL, INSTRUCTIONS IN THIS POST!! MAKE CASH NOW!!! Setting up and Configuration 0 December 12th, 2003 06:36 PM


All times are GMT +1. The time now is 08:00 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.