enabling/disabling buttons problem!?

J

Jerome

Hi,

I've got a form with a button and I want the button to get disabled if
pressed for this record. So far, so good. But I then want it enabled
again for the next record! And the same goes there: if button pressed
then disable it for THIS record, then when going to the NEXT record the
button should be enabled again.

Any help is appreciated!

Jerome
 
D

Dennis

In the Click Event of the button, put this code

..... perform what the button is supposed to do then ...
[SomeOtherControlOnTheForm].SetFocus
[ButtonName].Enabled = False

When you change records the default button state of enabled will return.
 
D

Dennis

Further to my last post, the button does not come back enabled when you
change records, so in the On Current Event of the form put this code

[ButtonName].Enabled = True
 
W

Wolfgang Kais

Hello Jerome.

Jerome said:
I've got a form with a button and I want the button to get disabled
if pressed for this record. So far, so good. But I then want it
enabled again for the next record! And the same goes there:
if button pressed then disable it for THIS record, then when going
to the NEXT record the button should be enabled again.

And, I guess that whan the user gets back to the first record, the button
should be still disabled?
You could use a Yes/No column in your table (Done), and use a ToggleButton
(tglDone) instead of a CommandButton to
display it's value. In the beginning of the BeforeUpdate eventprocedure of
the ToggleButton,
use something like this:

If tglDone = 0 Then
Cancel = True
tglDone.Undo
Exit Sub
End If
 
J

Jerome

Yes indeed! It was the 'Current Event' that I missed.

Thanks.

Further to my last post, the button does not come back enabled when you
change records, so in the On Current Event of the form put this code

[ButtonName].Enabled = True

:

Hi,

I've got a form with a button and I want the button to get disabled if
pressed for this record. So far, so good. But I then want it enabled
again for the next record! And the same goes there: if button pressed
then disable it for THIS record, then when going to the NEXT record the
button should be enabled again.

Any help is appreciated!

Jerome
 
J

Jerome

That's a good idea too! Thanks.

Wolfgang said:
Hello Jerome.




And, I guess that whan the user gets back to the first record, the button
should be still disabled?
You could use a Yes/No column in your table (Done), and use a ToggleButton
(tglDone) instead of a CommandButton to
display it's value. In the beginning of the BeforeUpdate eventprocedure of
the ToggleButton,
use something like this:

If tglDone = 0 Then
Cancel = True
tglDone.Undo
Exit Sub
End If
 
Top