Automatically inserting information into a table

C

CC

I have 1 table and many forms. The forms have filtered information that
pertains to that particular form. My question is how can I automatically
insert text into a particular column on a table based on the form. Say if
this form is about toys. The column is called "Type" in the table (this field
is not shown to the user), and for that particular record it would have a "T"
for toys in the "type" column in the table. Is there a way to do this?
 
W

Wayne Morgan

Are you wanting to place the value "T" in when they create a new record when
the form is filter for Toys? If so, place a hidden textbox on the form
(visible = no/false) and set the control source of this textbox to the Type
field. Set it's default value to the desired value, in this case "T". When
the user creates a new record, this default value will be automatically
entered for that field.

If the forms are the same except for the filter, you may find it easier to
have just one form to keep up with and change the filter as you open the
form. You could also set the default value of the Type control to match the
filter.
 
C

CC

I did that put but it is not automatically putting that in the table. I need
that "T" to automatically show up in the table when a record is created. Also
that "T" could change depending on what form I am in. Please help!
 
W

Wayne Morgan

I understand the "T" could change to something else, depending on which form
you're in. You would have to go to each form, add a textbox for this field
and set the Default Value of the textbox to the desired entry. This is why I
suggested changing the filter and the default in code as you open the form
if the forms are identical except for the filter and the default.

When you create a new record, the default values get filled in
automatically. The record won't be considered "dirty" though until you also
manually make an entry into at least one field. This keeps the defaults from
creating a record all by themselves if you move to the new record position
then change your mind. Since you don't want a single default value, you
can't set the default in the table. It will have to be set in the form's
control.

I tried what I suggested just to make sure there wasn't something funny that
happens when you hide the textbox, but it worked.
 
Top