Value determined by combobox selection

Robbyp2001

Registered User.
Local time
Today, 11:38
Joined
Oct 8, 2011
Messages
143
Good Morning Foks

I have a form [MainForm] and a continuous subform [subForm1]. The subform is based on a table [Ordertbl], which contains a payment method field [Paymeth]. The payment method defaults to (1)"Cash" every time a new record is created by selecting one of the 'classification1' options list [ItemClassLevel1ID].

The [Paymeth] options are 1.Cash 2.Credit Card and 3.Blank

So each new record automatically defaults to "Cash" with the option of very occasionally changing this to "Credit Card" when required.

When the [ItemClassLevel1ID] is selected the user has a choice of:
23.Administration
21.Clothing
22.Copybook
24.Loan Items
5.Photocopy
6.Stationary

The only option which actually requires a "Cash" or "Credit Card" selection is 2.Clothing, therefore the [Paymeth] box is irrelevent for all other options, even though it shows "Cash" on the screen. The Pament Method is seen only on invoices issued for clothing (No other invoices are produced).

What I would like to do, if possible, is to have the Paymeth box set to 3.Blank, or better still made invisible, when a new record is selected thus:

If [ItemClassLevel1ID] Then 23 - [Paymeth] = 3
If [ItemClassLevel1ID] Then 22 - [Paymeth] = 3
If [ItemClassLevel1ID] Then 24 - [Paymeth] = 3
If [ItemClassLevel1ID] Then 5 - [Paymeth] = 3
If [ItemClassLevel1ID] Then 6 - [Paymeth] = 3

and default to 1.Cash when:

If [ItemClassLevel1ID] Then 21 - [Paymeth] = 1

Whew, a bit long-winded, I know. Apologies to all readers.

How do I do this? I have attached a screenshot of the process if this helps.
 

Attachments

  • PayMeth.jpg
    PayMeth.jpg
    46.2 KB · Views: 110
Last edited:
You were almost there yourself

Code:
Private Sub ItemClassLevel1ID_AfterUpdate()

If Me.ItemClassLevel1ID = 21 Then
      Me.Paymeth = 1
Else
      Me.Paymeth = 3
End If

End Sub
 
Thank you so much Ridders. This works!

A bit cheeky, I know, but do you have any idea how to make the combo box invisible by default but appear when 'clothing' is selected?

If it's a difficult task, just ignore this. What you have given me is great.

Rob
 
Just add
Code:
Me.Paymeth.Visible = False 'or True
to your after update code.
If you are likely to step through different records on the form than add the same code to the OnCurrent event as well.
 

Users who are viewing this thread

Back
Top Bottom