How do I make It mandatory to click SUBMIT button

S

sunilkeswani

Is there some code I can put on the before update of the form, so that
it will not accept the mouse scroll submit and only accept if the
submit button is clicked?

Cheers
Sunny
 
B

BruceM

If I knew what the Submit button does I might be able to offer something
better, but one sort of generic choice would be to make a small box
(boxLock) somewhere on the form that is the same color as the background,
and to have code in the form's Current event that makes it invisible:
Me.boxLock.Visible = False

In the Submit button's click event, something like the following code:
Me.boxLock.Visible = True
followed by your code.

In the form's Before Update event:
If Me.boxLock.Visible = False Then
msgbox "Click the Submit button"
Cancel = True
End If

Does the submit button serve some purpose that is not served by merely
moving to another record?
 
J

John Vinson

Is there some code I can put on the before update of the form, so that
it will not accept the mouse scroll submit and only accept if the
submit button is clicked?

Cheers
Sunny

One way is to use a public variable. Open the Form's VBA code, and put

Public bOKToClose As Boolean

at the very top, above the first Sub statement.

In the Submit button's code, set bOkToClose to True; and in the Form's
BeforeUpdate event, check it - e.g.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Not bOKToClose Then
MsgBox "Please use the Submit button to save data"
Cancel = True
End If
End Sub

Or, disable the scroll wheel altogether - see www.mvps.org/access and
search for "scroll" for code to do so.

John W. Vinson[MVP]
 
B

BruceM

Could you explain that a bit more? It seems that bOkToClose must be False
unless you change it by running code that sets it to true. My not following
the suggestion is because I don't understand what a Boolean is in this
context.
 
J

John Vinson

Could you explain that a bit more? It seems that bOkToClose must be False
unless you change it by running code that sets it to true. My not following
the suggestion is because I don't understand what a Boolean is in this
context.

I did suggest

A Boolean datatype is a true/false variable. It is False when you
start; you set it to True in the Click event of the submit button; and
check it in the form's BeforeUpdate event.

John W. Vinson[MVP]
 
B

BruceM

Thanks for the reply. That could come in handy in a variety of situations.
It seems to be simpler than I had thought: it is False until you explicitly
set it to True. Would it revert to false when you navigate to another
record, or does it need to be reset in the form's Current event or something
like that?
 
J

John Vinson

Thanks for the reply. That could come in handy in a variety of situations.
It seems to be simpler than I had thought: it is False until you explicitly
set it to True. Would it revert to false when you navigate to another
record, or does it need to be reset in the form's Current event or something
like that?

oops - sorry! It reverts when you close and open the form, but it
should also be set in Form_Current.

John W. Vinson[MVP]
 

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