Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent moving to new record if conditions are not met

Status
Not open for further replies.

jpartney

IS-IT--Management
May 4, 2010
2
US
We want to prevent a user from moving to the next record during data entry if a certain field does not equal zero. This is a calculated field based on entries within the form and is used to see if the record will balance.
 
A common way is to use the BeforeUpdate event procedure of the form to enforce all the rules.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OK, I have tried to use the "Expression Builder", but that is not working for me. I am not familiar with "Code Builder" or "Macro Builder" to create this check. The form I created works, but if the data entry person does not check the balance text box, they can move on with a non-zero balance. Where can I find some information to create a code that will compare the value of the text box to "0" and not let it go to the next record if the text box is not equal to "0"? I am attempting to attach a snippet of the form I am using.
 
Hi
You should use the 'code builder' for that one.
In the 'BeforUpdate' theter should be a line something like that:
Code:
IF [i]YourTextBoxName[/i] <> 0 Then 
       Cancel = True
       [i]enter here a messagebox if you like[/i]
      End IF
 

In design view, open the properties window for the form.
You select the form by clicking the little black box in the upper left corner, where the rulers meet.

To open the properties window, right click the object and select properties from the pop up menu.

Next, select the Event tab.
Click in the box next to Before Update.
A dropdown arrow and an elipse button will appear.
Click the arrow and select Event Procedure.
Then click the elipse button to open your code window.

Finally, type the rest of your code between the Private Sub and End Sub lines.


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top