Prevent multiple clicks of command button?

C

CW

I have a "Save" button on my invoice creation form that calls up the next
sequential invoice number and drops it into the record, and saves all the
entered data.
Sometimes a user forgets they have already clicked it, or double-clicks by
mistake, and then we end up with several numbers being used for one invoice.
Is it possible to prevent multiple clicks - or rather, to nullify the effect
if somebody does do this?
Many thanks
CW
 
J

Jeanette Cunningham

Hi CW,
try putting the code that calls up the next invoice number in the before
update event for the form.

If IsNull(Me.InvoiceNumber) Then
Else
'code here to get the invoice number
End If

If there is a reason why the record can't be saved the invoice number won't
be saved.

If the record is dirty, your save button will call the before update event
by code like this

If Me.Dirty = True Then
Me.Dirty = False
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

CW

That's an interesting angle on it, anmd something I might use in other places
too. Presumably I need to put the ...Enabled = False bit towards the end of
the code... anyway, I'll play around with it... thanks John
CW
 
R

Rick Brandt

That's an interesting angle on it, anmd something I might use in other
places too. Presumably I need to put the ...Enabled = False bit towards
the end of the code... anyway, I'll play around with it... thanks John
CW

Just alter your code so it only assigns a number if the current record
doesn't already have one. Then pressing the button again doesn't hurt
anything.
 

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