Check For Submit Before Exiting Form

  • Thread starter Thread starter Charles J. via AccessMonster.com
  • Start date Start date
C

Charles J. via AccessMonster.com

I have a data entry form that has a Menu item to "submit" entries. But, I
have found that if a user partially completes the data entry form and decides
to click on another form or a Menu Item, a record is automatically created
anyways without clicking the submit button.

Could you help me with code, in either after UPdate of form or BeforeUpdate,
to check if the submit button was clicked and if not, do not save the record
to the table?

Thanks,
Charles
 
Hi Charles,

Don't use a databound form i.e., don't bound any query or table to form to
enter the data. Instead use an insert query to update the table once the user
had clicked on Submit.

Regards,
Upendra
 
Hi,
I have to bound the form. I'm using a lot of fields and properties tied to
combo boxes, etc. when I remove the table from the form all my fields have
errors.

Is there another way to check, maybe an error routine that would keep the
records from being written to the table if the "submit" button is not enter??

thank,

Upendra said:
Hi Charles,

Don't use a databound form i.e., don't bound any query or table to form to
enter the data. Instead use an insert query to update the table once the user
had clicked on Submit.

Regards,
Upendra
I have a data entry form that has a Menu item to "submit" entries. But, I
have found that if a user partially completes the data entry form and decides
[quoted text clipped - 7 lines]
Thanks,
Charles
 
Create a module level variable, set it to True when the button is clicked,
and cancel the save if it is not true:

Dim mbAllowSave As Boolean

Private Sub Form_BeforeUpate(Cancel As Integer)
If mbAllowSave Then
mbAllowSave = False
Else
Cancel = True
MsgBox "Click the Submit button to save."
End If
End Sub

Private Sub Submit_Click()
mbAllowSave = True
RunCommand acCmdSaveRecord
End Sub


In general, it should not be necessary to do that. You can validate
everything before the save in Form_BeforeUpdate, and respond to a save
(doing whatever else needs to be done) in Form_BeforeUpdate. Jamming the
user into the form where they must click the button is unnecessarily
frustating in many cases, e.g. I would not buy a program that behaved like
that.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps.org.

Charles J. via AccessMonster.com said:
Hi,
I have to bound the form. I'm using a lot of fields and properties tied
to
combo boxes, etc. when I remove the table from the form all my fields
have
errors.

Is there another way to check, maybe an error routine that would keep the
records from being written to the table if the "submit" button is not
enter??

thank,

Upendra said:
Hi Charles,

Don't use a databound form i.e., don't bound any query or table to form to
enter the data. Instead use an insert query to update the table once the
user
had clicked on Submit.

Regards,
Upendra
I have a data entry form that has a Menu item to "submit" entries. But,
I
have found that if a user partially completes the data entry form and
decides
[quoted text clipped - 7 lines]
Thanks,
Charles
 
Back
Top