acSaveRecord issue and required fields

joyd

New member
Local time
Today, 04:31
Joined
Nov 10, 2009
Messages
2
i have a button for exporting a single record into a report and e-mail... the
problem is that when the record needs to be saved first, but i don't want
this to be allowed without all the required fields filled in. acSaveRecord
produces an error if not all fields are filled in, sending you to the
debugger. i have created a macro from the standard save button and have it
run before the rest of my code, but when doing so, i get the "required field"
error message from the macro, but the code continues to run, creating the e-
mail, even though not all required fields are filed. does anyone have a
solution?

Thanking you in advance,

thanos
 
IMO it is better to be pro-active reather than try to manage something like this after the fact. By that I mean, don't even make the option available to the user until you are sure that all requirements for the option have been met.

You can do this by making your button to be disabled as its default status. Then use VBA code in a user defined function that will check to be sure that the requirements for data entry have been met before the button is enabled and thus available to the user. Another "cancel" button would be required to allow the user to opt out when they wanted to without completing the requirements.

The Code would look something like this:

Function ChkDataEntry()
If Not IsNuLL(Me.NameOfSomeControl) _
And Me.NameOfOtherControl > 0 _
And Me.NameOfAnotherControl = 3 then
Me.NameOfButton.Enabled = True
Else
Me.NameOfButton.Enabled = False
EndIf
End Function

You would just refer to your own controls in the function code above and place this function in your forms module.

Then you call the function from the AfterUpdate event of each of the controls that are part of the requirement like thisL

ChkDataEntry
 

Users who are viewing this thread

Back
Top Bottom