Help! Using macro's to validate Null fields/add timestamp/gotoNewRec Form_BefreUpdate

Ignoth

Registered User.
Local time
Today, 12:22
Joined
Apr 26, 2012
Messages
11
Would like to solve this using the macrobuilder because I don't know VBA and due to time constraints don't really have time to learn it. If one could help me figure out whats wrong with my macro, or help me make a new one, or even just adapt a code in VBA to my specified fields/controls/form and walk me through it that would be most appreciated.

The problem I'm having in Form_Before_Update is that if the first field is filled, but the second isn't, it will still allow the record to be "saved" upon "Submit Request" (Macro- Go To- New Record ). If both fields Is Null, nothing will happen upon pressing the "Submit Request" button. If only the SECOND field ([Sort #]) is Is Not Null, but the first field ([Requestor]) is Null, it will prompt: (MsgBox) "Please fill in the Requestor field," (press ok) then ANOTHER MsgBox prompt (information error) "You cannot go to the specified record: You may be at the end of a record set", crash the "Submit Request" button "frmNewPartsRequest : Submit Request btn : OnClick : Embedded Macro. Action Name: GoToRecord Argument-1, New.... [Stop All Macros]

This is my exact Form_Before_Update macro, maybe there is something wrong with it:

If Forms![frmNewPartsRequest]![Requestor]! Is Null Then
Cancel Event
Msg Box -
"Please fill in the Requestor field"
Go To - Control Source - Requestor
-If Forms![frmNewPartsRequest]![Sort #]! Is Null Then
Cancel Event
Msg Box -
"Please provide the Sort #"
Go To - Control Source - Sort #

Here is my Control_Button on the form:
(Macro) Go To - Record - New

How do I get the "GoTo-Record-New" to stop crashing if a field is null, and apply the timestamp in the Before_Update? I've tried pasting this macro in the form/control/before_update/after_insert and have run into the issue several times over.



Thanks!
 
In VBA you test for Null with the IsNull() function.

I guess that's true in Macros too so change

Forms![frmNewPartsRequest]![Requestor]! Is Null

to

IsNull(Forms![frmNewPartsRequest]![Requestor])

and same for the other If
 
Vila, I changed the syntax of that code to match yours and it appears to work the same way I had it. The problem is that when I press my "Submit (GoTo-NewRecord)" Button with those fields null, it creates errors that I need to fix: (MsgBox) "Please fill in the Requestor field," (press ok) then ANOTHER MsgBox prompt (information error) "You cannot go to the specified record: You may be at the end of a record set", crash the "Submit Request" button "frmNewPartsRequest : Submit Request btn : OnClick : Embedded Macro. Action Name: GoToRecord Argument-1, New.... [Stop All Macros]

Why is my control button to "GoTo-NewRecord", not working in accordance with the form before_update and how do I make it so it does?
 

Users who are viewing this thread

Back
Top Bottom