Defaults in new record entry.

M

MikeC

Hi

I have a table containing records relating to customers.
They are displayed as continuous forms view in a subform of the customer
data form so if I have a customer on the screen I can scroll through his
records in the subform

The "Description" field in the subform is a Combo Box control which diplays
a list of possible entries from a products table. This allows me to select
the Description for a new record.

The list source table for the combo box has other fields that I would like
to be inserted as default values in the other fields of the new record. How
can I do this?

Thanks in advance
 
A

Al Camp

Mike,
Let's say that in your combo, Description is in visible column 1 and
Price is in column 2 and MadeBy is in column 3. Using the AfterUpdate event
of the combo...
[Price] = cboDesc.Column(1)
[MadeBy] = cboDesc.Column(2)
(Programatically, combo columns are numbered 0, 1, 2, 3, etc...)
 
M

MikeC

Thanks Al. Unfortunately I get a Type Mismatch error when I try it.

This must be a very common requirement. For example in an accounting
application you would have a Product List that included prices.

When you input an order you would want to pick a product and then have the
fields from the Product List populate the order screen.

When you finish any amendments to quantity/price/desription etc you would
then want the screen fields saved to an order table.
--
Mike


Al Camp said:
Mike,
Let's say that in your combo, Description is in visible column 1 and
Price is in column 2 and MadeBy is in column 3. Using the AfterUpdate event
of the combo...
[Price] = cboDesc.Column(1)
[MadeBy] = cboDesc.Column(2)
(Programatically, combo columns are numbered 0, 1, 2, 3, etc...)
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

MikeC said:
Hi

I have a table containing records relating to customers.
They are displayed as continuous forms view in a subform of the customer
data form so if I have a customer on the screen I can scroll through his
records in the subform

The "Description" field in the subform is a Combo Box control which
diplays
a list of possible entries from a products table. This allows me to select
the Description for a new record.

The list source table for the combo box has other fields that I would like
to be inserted as default values in the other fields of the new record.
How
can I do this?

Thanks in advance
 
A

Al Camp

Mike,
We need more details...
What fields are you trying to update (Indicate the From fields and To
fields, and the Type of each)
Also, you didn't indicate which field is posting the Type Mismatch. Do
all the updates fail?
What is your AfterUpdate code? (example... use your own names and column
numbers)
Private Sub cboDescription_AfterUpdate()
Me.[Price] = cboDesc.Column(1)
End Sub

There must be a difference between the field definitions in your Product
combo coloums vs. your Orders form fields. Make sure both sets of fields
are the same Type/Length etc...

Experiment with only updating one field at first (like Price), and when
that works, add the next one.
**Make certain you are updating the right field on your form with the right
column number.**

If you still have problems, provide details of the field definitions for
both tables, how you have your combo set up, your form fields, and your
AfterUpdate code for the combo.
-
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


MikeC said:
Thanks Al. Unfortunately I get a Type Mismatch error when I try it.

This must be a very common requirement. For example in an accounting
application you would have a Product List that included prices.

When you input an order you would want to pick a product and then have the
fields from the Product List populate the order screen.

When you finish any amendments to quantity/price/desription etc you would
then want the screen fields saved to an order table.
--
Mike


Al Camp said:
Mike,
Let's say that in your combo, Description is in visible column 1 and
Price is in column 2 and MadeBy is in column 3. Using the AfterUpdate
event
of the combo...
[Price] = cboDesc.Column(1)
[MadeBy] = cboDesc.Column(2)
(Programatically, combo columns are numbered 0, 1, 2, 3, etc...)
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

MikeC said:
Hi

I have a table containing records relating to customers.
They are displayed as continuous forms view in a subform of the
customer
data form so if I have a customer on the screen I can scroll through
his
records in the subform

The "Description" field in the subform is a Combo Box control which
diplays
a list of possible entries from a products table. This allows me to
select
the Description for a new record.

The list source table for the combo box has other fields that I would
like
to be inserted as default values in the other fields of the new record.
How
can I do this?

Thanks in advance
 
M

MikeC

Hi Al

Thanks for the suggestions. Still couldn't get it to work that way so I did
it as follows, which turned out to be quite simple.

Create the form which will display the order records (continuous forms view)
In the form footer place a combo box that will get its data from the
products file. Column 0 is the Product Code, Column 1 is the Description
Stick a Command Button next to it that runs a macro to add a record to the
order records table.
The macro does two things:-
1. Run a query which uses the combobox value to select the desired fields
from the product file and append them to the orders file.
2. Requery to update the orders listing.
--
Mike


Al Camp said:
Mike,
We need more details...
What fields are you trying to update (Indicate the From fields and To
fields, and the Type of each)
Also, you didn't indicate which field is posting the Type Mismatch. Do
all the updates fail?
What is your AfterUpdate code? (example... use your own names and column
numbers)
Private Sub cboDescription_AfterUpdate()
Me.[Price] = cboDesc.Column(1)
End Sub

There must be a difference between the field definitions in your Product
combo coloums vs. your Orders form fields. Make sure both sets of fields
are the same Type/Length etc...

Experiment with only updating one field at first (like Price), and when
that works, add the next one.
**Make certain you are updating the right field on your form with the right
column number.**

If you still have problems, provide details of the field definitions for
both tables, how you have your combo set up, your form fields, and your
AfterUpdate code for the combo.
-
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


MikeC said:
Thanks Al. Unfortunately I get a Type Mismatch error when I try it.

This must be a very common requirement. For example in an accounting
application you would have a Product List that included prices.

When you input an order you would want to pick a product and then have the
fields from the Product List populate the order screen.

When you finish any amendments to quantity/price/desription etc you would
then want the screen fields saved to an order table.
--
Mike


Al Camp said:
Mike,
Let's say that in your combo, Description is in visible column 1 and
Price is in column 2 and MadeBy is in column 3. Using the AfterUpdate
event
of the combo...
[Price] = cboDesc.Column(1)
[MadeBy] = cboDesc.Column(2)
(Programatically, combo columns are numbered 0, 1, 2, 3, etc...)
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Hi

I have a table containing records relating to customers.
They are displayed as continuous forms view in a subform of the
customer
data form so if I have a customer on the screen I can scroll through
his
records in the subform

The "Description" field in the subform is a Combo Box control which
diplays
a list of possible entries from a products table. This allows me to
select
the Description for a new record.

The list source table for the combo box has other fields that I would
like
to be inserted as default values in the other fields of the new record.
How
can I do this?

Thanks in advance
 
Top