If I create a form with the wizard and later decide I need to add another field do I have to re-crea

  • Thread starter Mister John Doe
  • Start date
M

Mister John Doe

I have not been able to find out from the Microsoft help information
what the answer to this is, so I thought I'd pose it here...

Unfortunately for me, this happens all the time.

I use the wizard to create a form. When I create the form I place on
it all the fields that I think I am going to need. Of course, I am
using that double-column window that the wizard presents to use. It's
really easy to do that, except for this:

I sometimes will spend hours modifying the form, placing triggers and
event handling code into the module behind the form. Then I determine
that I need another field. Maybe I didn't think about it enough when I
created the form, but there I am.

So I add another control, let's say a text box or a combo box. Then I
assign it a Control Source to the table and the field that I want to
add to the form. However, I am placing this field there because I want
to use it for creating or updating a new record (data input). So, when
I go to add data to the new field, or if I programmatically try to
assign a value to the control, I get an error message that basically
tells me I can't assign a value to the field.

I'm assuming that the problem is because when I set up the new control
to have a Control Source of a specific field from a table, then that
must be telling Access to get data FROM that field/table, and not to
allow me to put data INTO the field/table.

But if I leave the new control unbound, then I have to add code to
"manually" build a query and an SQL statement to update the data to
the field/table. Otherwise I have to trash the whole form and start
all over, adding all the triggers and event handling code, etc. (Then
later I find that I need to add ANOTHER field and I go round and round
in circles.)

I am probably wasting a lot of time doing things this way. It seems to
me there MUST be a way to add a field to a form, bind it to a table,
and use it for data input in the same manner that the other fields are
there when the wizard built the form in the first place.

Anyone got any suggestions on what I need to do?
 
A

Albert D. Kallal

The concept you need to learn/grasp is that most/many forms are going to be
based on a query.

That query has only the fields you include AT THE TIME of creating.

So, take a look at the forms data source..and simply see/look/check what the
data source of the form is. You can simply modify that query to include the
additional fields you added to the table.

And, if you wish, you can set the forms data source directly to the table,
and thus any new field you create will show up in the field list for the
form.

The main advantages of using a query in place of a table for a form is that
you can set the sort order in the query, and also bring in (lookup fields)
from other tables when using a query.
 
D

Dan Artuso

Hi,
I'm not sure I completely understand your dilemma but...

A form's recordset can be a table or a query. The controls on that form can only be bound
to the the fields in the table or query that is the form's recordset.
Does this make sense?
You can certainly add more controls to a form and bind them to any of the fields in the underlying
recordset. This means you can display data AND add or update it as well.

Are you perhaps trying to pull data from tables that are not in the form's recordset?
 
M

Mister John Doe

Thank you very very much.

I did not think about things being set up the way you described it but
when I read what you posted it made perfect sense.

So I set up my forms based on the underlying query construct and I was
able to do in a few minutes what was taking me several hours and
sometimes days to do.

Your explanation has saved me a whole bunch of time, hassle, and
frustration.

Again - thanks.
 

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

Top