Question on validation rule...

MSUKevin

Registered User.
Local time
Today, 20:26
Joined
May 16, 2001
Messages
75
I haven't been able to find the answer to this on my own, so I was hoping one of you good people could help me out!

I have a form, [products], that lists sale items. At the bottom of the form I have 3 txt boxes that sum up the information.

The first txtbox, [sale_total], calculates the amount of the current purchase.
The second txtbox, [cash_received], is for the user to enter the amount of money given by the customer.
The third txtbox, [change_due], takes the amount entered in the [cash_received] txtbox and subtracts the amount from the [sale_total] txtbox.

This is done so the user doesn't have to figure out how much change to give the customer... easy enough... but,

What I want to set up is a validation rule in the [cash_received] txtbox. One that will not let the transaction continue if the amount entered in [cash_recieved] txtbox is less than the amount in the [sale_total] txtbox.

I tried to build an expression in the validation rule property for the [cash_received] txtbox like this:

= [cash_received]>[sale_total]

with a validation message that stated the amount wasn't enough to cover the cost. This didn't work because even when I entered an amount 10x the sale_total I recieved the validation message.

I'm sure there is a way to write this expression in code but I don't know how to do coding that well (in my 2nd week of class for VBA). If someone could help I would be forever greatfull

(Also - sorry this is so lengthy but I wanted to be clear)
smile.gif


cheers and good Friday,
Kevin
 
well, this my get you started:
for the field you tried to put a validation rule on, go to the BeforeUpdate property, and add some VBA code:
if Me.cash_received < Me.sale_total Then
MsgBox "Dude, that's not enough money"
Cancel = true
End IF

Setting cancel to true will not allow that field to be updated. Of course you might need to also check that Me.cash_received isn't null, or you might get an error.
 
Had the same sort of problem.Our way was fine,but yours was better
smile.gif
 
dhoffman,

Worked like a charm!!!!
smile.gif


Thanks for your help on this matter, I really appreciate it!

Sincerly,
Kevin
 

Users who are viewing this thread

Back
Top Bottom