Validation rule in an access form on an unbound text

thedeadzeds

Registered User.
Local time
Today, 03:19
Joined
Jan 8, 2014
Messages
40
Hi All,

Is there a way to add a validation rule in an access form on an unbound text box. This box is currently doing a calculation of others. If the figure is not between 0 And 0.3125 then I do not want the user to be able to move on. For some reason if I enter ‘Between 0 And 0.3125’ in the validation rule it doesn’t seem to do anything. I can only assume its because its an unbound text box. Data attached please see Frm_Input and text box total standard hours.

Many thanks
Craig
 

Attachments

Since that's a calculated field, you need to attach an event to both of the fields the user can input data to and do the validation via VBA. Here's the steps to take

1. Create a function called something like ValidateData(). This will look at the values in both those inputs, do your validation and then spit out an error message if the result is out of range.

2. Add an OnChange event to input1 which calls ValidateData().

3. Add an OnChange event to input2 which calls ValidateData().

Then whenever input1 or input2 changes, your form validates the resulting value and lets the user know if its invalid.
 
thanks for that, its a little above my access abilities unfortunately. I have very little experience with functions
 
What you want to do isn't high level stuff, its actually a good intro project into VBA. Do this:

1. In design view of your form, right click on the input1 field and choose 'Properties' from the dialog that appears.

2. In the menu that appears, click on the 'Event' tab and then click the elipses (...) next to the 'On Change' item.

3. In the dialog that pops up, highlight 'Code' and press the 'Ok' button.

4. Paste this code into the VBA code area:

msgbox("You Changed The Value")

5. Exit the code module, exit the properties menu, exit the form and save whenever prompted.

6. Go into your form in regular view and change the value on input 1. You should get a message box.

From there, you need to write your validation code. Post back here any issues you have.
 
Thanks for that it makes sense. However, its kind of doing the same as an iif statement I have already written in the form. What I'm trying to achieve is to ensure if the Total Standard Hours (Text62) is not Between 0 And 0.3125, then the user cannot physically log the entry.

Thanks for your time anyway much appreciated.
 

Users who are viewing this thread

Back
Top Bottom