What is the code to enable/disable a command button in Access ...

L

LM19

I have set up a switchboard in Access 2003 that enables others using the
database to easily access the forms that they need without having to search
through all the other information that is on the database and have set up a
'Back' command button so that navigation between the other switchboards that
are linked to the main default one is easy. I would like the 'Back' button
only enabled on pages other then the main default page as you can't go 'Back'
any further then that page. Can anyone help me with the code that I would
need to use to do this? I have attempted using the following code but it
allows me to press the 'Back' button once and then disables it entirely, no
matter what page you are on. Here is the code:

If Me![Argument] = "Default" Then
' We're on the Default Page
' Disable the back button
Me.Back.Enabled = False
Else
' Enable the back button
Me.Back.Enabled = True
End If

Thanks,
LM
 
B

bcap

I would suggest that the problem is not so much with the code itself as to
when it gets executed. So, what is the context? What event procedure is
this code in, and how/when does [Argument] get it's value?
 
L

LM19

Ok, I'm really new to using Access and have never been taught anything so all
that I know (which isn't much!) has just been through guess work, so I'm not
quite sure that this is what you were after, but this is the event procedure
that I am trying to run the code in:

Private Sub Back_Click()
' Move back to the switchboard page that is marked as the default.

Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
->
End Sub

I have tried to run the event with the code in where the arrow is but as I
said before, this doesn't disable the button on the default page, but then
when you press it on any other page, the button is disabled and you can't use
it again.

I hope that this is what you were asking for. I'm sorry if it's not.
 
L

LM19

Don't worry about this as I have now found the answer. I ended up finding an
example of a switchboard that had the same code but in another place and by
me moving the code to another event procedure and it worked! Thanks anyway
for trying to help 'bcap'! If anyone out there is trying to do the same thing
and having trouble, the webpage that I found the answer on is:

http://www.accessmvp.com/JConrad/accessjunkie/switchboardfaq.htm
 

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