Default Values on Form Combo based on Fields in Customer Table

  • Thread starter Thread starter scs
  • Start date Start date
S

scs

Here's one I could use some assistance with:

I have a payment table and a payment form. When my customer is paying for a
membership I enter a date and then tab to a combo to grab the customer
(cboCustomer), then I tab to another combo and choose the membership type
(cboMembershipType) then I tab and type the dollar amount into the Amount
control.

My question is: If I were to setup a couple of fields in the Customer table
(tblCustomer) called DefaultMembershipType and DefaultMembershipAmount,
would it be possible to set the default property of the cboMembershipType
and the Amount controll to equal the fields in the customer table and fill
accordingly? If so could someone please tell me how or point me to info.
Thanks very, very much. This forum is wonderful. My wife is starting to
think I'm a programmer or something. ha ha :)
 
yes, it's possible. since you're using a combo box control to choose the
customer (cboCustomer), it's actually pretty easy. add the two new fields to
your table. in the form design view, go to the combo box and change the
RowSource property to include those two fields. make sure you change the
ColumnCount property to include the additional fields. suggest you also set
the length of the two fields to zero (0") in the ColumnWidth property. the
result is that you've added two columns to the combo box, which hold the
default values for each member, so the values are available for use
elsewhere in the form; and you've hidden the additional columns so they
won't be seen in the combo box's "droplist".

in the combo box control's AfterUpdate event procedure, add the following
code to set the value of the cboMembershipType and Amount controls, as

Me!cboMembershipType = Me!cboCustomer.Column(n)
Me!Amount = Me!cboCustomer.Column(n)

you'll have to replace the "n" with the correct column index number for each
value. the columns in combo box controls are zero-based, so the first column
(counting from left to right) is 0, the second column is 1, the third column
is 2, etc.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top