Adding to a form

T

Té

I have created a form, however I want to pull from another table and add that
to my form. How can I do this?
 
J

John W. Vinson

I have created a form, however I want to pull from another table and add that
to my form. How can I do this?

It depends on how the tables are related and what you want to do. Typically if
you have two tables in a one to many relationship you would use a Form based
on the "one" table, with a Subform based on the "many", using the primary key
and foreign key field as the master/child linking field respectively. Tom's
suggestion of a Query joining the two tables as the recordsource for the form
can often be useful but may not be updateable and may show confusing repeats,
depending on how the tables are related.
 
T

Té

So after the form is created there is no way I can switch design view and add
a field from another table that isnt a part of my form? It has to be done
from the start?
 
J

John W. Vinson

So after the form is created there is no way I can switch design view and add
a field from another table that isnt a part of my form? It has to be done
from the start?

I did not say that, nor - I hope! - did I say anything that resembles that.

Of course you can change the design of the form. If you're using the Query
approach, create the query; open the form in design view; select the
Recordsource property and change the tablename to the name of the query.

If you want to add a subform, open the form in design view and add a Subform.
Move the controls around to make room, or add a Tab Control and cut and paste
controls onto tab pages if you need more screen real estate.
 
R

Rick Brandt

Té said:
So after the form is created there is no way I can switch design view
and add a field from another table that isnt a part of my form? It
has to be done from the start?

A form has ONE RecordSource, but that RecordSource can be a query that pulls
data from more than one table. This is generally not a good idea because
(in many cases) a query based on multiple tables produces read only output
which is most of the time not what you want on a form.

That being said the RecordSource of a form be it a table or query can be
changed at any time by going into design view and making the change.

You can also put controls on your form that pull data from other tables for
viewing only. This data (pulled using expressions that can look at other
tables) can thus be displayed on your form, but it would not be part of the
form's RecordSource and would not be editable.
 
T

Té

Rick I tried using the expression, but I dont understand how it works. I
clicked on control source and in the expression window I can see the other
tables, but I dont know what to do from there.
 
R

Rick Brandt

Té said:
Rick I tried using the expression, but I dont understand how it
works. I clicked on control source and in the expression window I
can see the other tables, but I dont know what to do from there.

DLookup() would be the most common, but any of the domain functions DMax(),
DMin(), DCount(), etc..

You can also use Subforms, ComboBoxes, ListBoxes.
 
R

Rick Brandt

Té said:
So I need to type =DLookup(the table I want to choose from)?

See the help file.

=DLookup("some field", "some query or table", "optional criteria")
 
T

Tom Wickerath

Hi Té,
So I need to type =DLookup(the table I want to choose from)?

That really depends on what you are trying to do. I still don't have a clear
idea of what it is that you are trying to accomplish. In your first posting,
you wrote: "I have created a form, however I want to pull from another table
and add that to my form."

What exactly does this statement mean? Does it mean that you simply want to
display a value for reference (e.g. read only) from another table? Or does it
mean that you want to be able to edit this other value? Help us out a bit
here. What is the name of table that your form is currently based on? What
are the names and data types of the fields? (I'm hoping that this information
gives us an idea of the type of data that your form is used for). Same
questions for the new table that you want to pull data from. Is there more
than one field from the new table? Can you provide some sample data? Are your
tables related in any way?


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
Top