button that can only be pressed once per record.

mafhobb

Registered User.
Local time
Today, 13:13
Joined
Feb 28, 2006
Messages
1,249
I have a button on an unbound form that should only be pressed once for each record that it shows.

It is an "accept" button

For example the db filters through to a record and if the user clicks on that command button, then the item is accepted for review. In my case it makes no sense that this item is accepted for review at any other time, so I want this button to be greyed out from this point on when this record is shown.

How do I do this?

thanks

mafhobb
 
add a yes\no field to the record source table and on click update it to false and add code to the form's current event me.[controlname].enabled = [fieldname]
 
I think I would just add the yes/no fld and put a check box on the form for it and leave the button part out.
 
it's not bad....but i would go with button if you don't want that the end user should be able to un-check it , also i believe that a disabled button is nicer than a check box ...
 
So long as it's not a continuous form then it's straightforward:

In the form's current event check whether the record has been reviewed and enable the button if it hasn't, disable it if it has.

At the end of the button's click event (perhaps after checking no errors) disable it.

Will have to move focus to another control before it can be disabled in both events.

I'm not sure how you would know whether a record has been reviewed. Let's say there's a dtReviewed field that is null until this button is pressed at which point it gets today's date:

Code:
Private Sub Form_Current()
    If Me.ActiveControl.Name = "cmdReview" Then Me.SomeOtherControl.SetFocus
    Me.cmdReview.Enabled = IsNull(Me!dtReviewed)
End Sub

Private Sub cmdReview_Click()
    'Do reviewing stuff
    Me!dtReviewed = Now()
    Me.SomeOtherControl.SetFocus
    Me.cmdReview.Enabled = False
End Sub

I hope that's what you were after and makes sense.
 
it's not bad....but i would go with button if you don't want that the end user should be able to un-check it , also i believe that a disabled button is nicer than a check box ...

The 'nicer' part is subjective isn't it? And if you do a button you'll have to contend with a bunch of code monkey business like Vila is proposing... ugh. ;)

Edit: My bad, Vila did say 'not on a continuous form' which I assumed he did have :)
 
And if you do a button you'll have to contend with a bunch of code monkey business like Vila is proposing... ugh. ;)

It's only a little bunch.

We're all just monkeys with technology so just pretend they're bananas.
 
Well, I made a new table where a simple yes/no value is stored and look at that table on load to see if the button needs to be greyed out or not.

Thanks everyone for your help!

mafhobb
 

Users who are viewing this thread

Back
Top Bottom