Form Valication (1 Viewer)

Tupacmoche

Registered User.
Local time
Today, 00:22
Joined
Apr 28, 2008
Messages
291
Hi Form Masters,

I have a form that has several payment methods that all go into a single backend database field called Amount. If a person pays by check the textbox is called txtcheck, if by cash it is txtCash ect there is textboxes wire, credit card and others. But, they all are bound to an SQL field called Amount. Before a form is closed I have to check that if Amount is over 100K another form was filled out. I want to avoid having to check six or more fields that are really referring to one column in the database. But when, I tried this:

If Nz(dbo_myTable.Amount) >= 100000 Then
MsgBox ("You must fill out a StewardShip form to continue...")
Else
End If

I get run-time error 424 object required. When I replace the table field name with an Access textbox that holds the value it works. But now I have to check every textbox. Is there an easier way?:mad:
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:22
Joined
Oct 29, 2018
Messages
21,446
Hi,

If all textboxes are bound to the same field, then you should be able to check just one of them. Don’t all the textboxes have the same value in them anyway?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:22
Joined
May 7, 2009
Messages
19,226
the easiest way is to make a ComboBox the the Mode of Payment with the rowsource coming from table or Value/List.

then you will only need to use 1 txtAmount textbox.

if you prefer the table (which is easy to add/remove some mode):

tblPayMode

FieldName FieldType
==============================
PaymentMode Short String

eg:
Cash
Cheque

say you add a combo to the form (cboPaymode), Bound it to the field in your table, and rowsource of the combo:

Select Paymentmode from tblPaymode;

==
if you don't want to use table, use Value List as Rowsource Type:

Cash;Cheque; ...etc.
 

missinglinq

AWF VIP
Local time
Today, 00:22
Joined
Jun 20, 2003
Messages
6,423
As theDBguy said, if all of these Controls are Bound to a single Field, in the underlying Table, then all of the Textboxes (txtcheck, txtCash, ect.) will show the same Value...and you won't be able to tell how payment was made!

You need to either use arnelgp's method, with a Combobox, or use an Option Group, to indicate how the payment was made...and a single txtAmount Control, Bound to the Field in your Table, to enter the amount paid...then check the amount in that single Field, for your Validation.

Linq ;0)>
 

Tupacmoche

Registered User.
Local time
Today, 00:22
Joined
Apr 28, 2008
Messages
291
Follow-up question on this process. As, I mentioned in the post a form needs to be filled in if a record Amount is >= 100000 but the user may have filled in the form. So, the question is how can, I determine that the form was processed (filled in) only if it was not do I need the other code to warn the user. So, to summarize if the form is filled in because the gift is 100K then no warning is needed. But if the form is not filled in and the gift is 100k or more then they get the warning.
 

Users who are viewing this thread

Top Bottom