Disable Command for Set of Records Prior to New Feature

gnarpeggio

Registered User.
Local time
Today, 04:11
Joined
Jun 22, 2010
Messages
74
How to Disable a Command Button for a Group of Existing Records

Hello,

I'm trying to develop a code for a command button that will disable it as it will have no purpose on previous records.

My command button is set up with an Application.FollowHyperlink function that will match the record's ID number with the stored file name and open it when clicked. Since this process is going to coincide with newer records only (this procedure hasn't been implemented yet), I need my DB to ignore the set of existing records entered and only enable the button beginning on the record ID I choose.

In a nutshell, I'd like to have a validation code that states:

If [ID] is between 1 - 999, Then
[CmdButton] = No

Is there a way to do this? Any help is appreciated!

Thanks!
 
Last edited:
I would think you'd have to set this somewhere in a table, or maybe in code somewhere. Would you do this only on one form? every time the program is opened?

one thing that springs to mind, is to have an invisible box on your form that you can throw these specs into. thus, on the current event of the form, perform a one line check of the content of that box and disable the button based on the return of that code?

how does that sound?
 
You could use something like the following in the Form's On Current event;
Code:
If Me.ID <1000 And Me.ID > 0 Then
     Me.YourCommandButtonName.Visible = False
Else
     Me.YourCommandButtonName.Visible = True
End If
This would hide button if the ID is between those two values. If you simply want to disable the button rather than hide it you could put the following in it's On Click event;
Code:
If Me.ID <1000 And Me.ID > 0 Then
     MsgBox "Sorry this button has no function on This Record"
     Exit Sub
End If
 
John,

The first solution you offered works fine. I will simply hide the button for existing records that don't have a scanned document associated with them. This will help avoid a million questions from my staff when they try to open a non-existent file.

Thanks for the help folks!
 

Users who are viewing this thread

Back
Top Bottom