Continues Form

  • Thread starter Thread starter Peter Morris
  • Start date Start date
P

Peter Morris

Can someone please give me step by step
instructions for creating a continues form that shows
the results of a SQL query.
 
Can someone please give me step by step
instructions for creating a continues form that shows
the results of a SQL query.

You kind of have to clarify what you mean by results of the sql?

Do you have a query built, and saved?

Ok, lets assume you built that query, and saved it in the query builder
(after all, that is where one builds the sql in ms-access...right?).

On the forms tab, click on the new (to create a new form).

You get a list of options:
Design View
Form wizard
AutoForm: Columnar
AutoForm: Tabular
etc.

If your sql query has EXACTLY the fields you want, then choose
AutoForm:Tabular from the above, select your query in the combo box, and
click ok.

You are done!!

You can also choose Form wizard from the above...and go step by step through
the prompts.

select "Form Wizard", and then "ok"

the next screen allows you to select your sql query.

So, select your query, and you can see the list of fields you want to
display. Choose which fields you want from your sql to show.

Now, hit next button for next screen.

Here you can choose a "tabular" format (note, that this format is based on a
CONTINUES form...so, choose this to get a continuous form).

At this point, hit the finish button, and you will get a continues form.....

You can bring up the this form in design mode, and then take a look at the
settings to see how this was done. Pay attention to the forms "other" tab,
and the settings used here (and, if you are new to ms-access, make sure you
select the form first before you view the forms property's in design mode -
(use ctrl-r, or edit->select form, and THEN view the properties sheet).


So, the above will result in your sql query being sent to a form.

It is not at all clear in which context, and when, or how, or at what point
in your application you want to send the sql to the form.

Do note that you can also change or set sql for the form in code. You of
course will have to ensure that the same field names exist in your sql and
they match controls on the form. So, setting the sql in code is rather easy.
Lets assume we built the continuous form based on table called tblCustomers.

To set the sql in code, we can then go:

dim strSql as string

strSql = "select * from tblCustomers where City = 'Edmonton'"

me.RecordSource = strSql

It is really only 3 lines of code (and, really, I could have written the
above code on ONE line). So, we are not taking about any large amount of
code here...

So, you can shove a sql string directly into a continuous form using the
above. And, ms-access is kind to you in that changing the recordsouce as
above also triggers a requery/re-load of the data for the form (again,
ms-access saves you having to issue a re-query of the form in code.
 
Albert D.Kallal said:
You kind of have to clarify what you mean by results of the sql?

Do you have a query built, and saved?

Ok, lets assume you built that query, and saved it in the query builder
(after all, that is where one builds the sql in ms-access...right?).

On the forms tab, click on the new (to create a new form).

You get a list of options:
Design View
Form wizard
AutoForm: Columnar
AutoForm: Tabular
etc.

If your sql query has EXACTLY the fields you want, then choose
AutoForm:Tabular from the above, select your query in the combo box, and
click ok.

You are done!!

You can also choose Form wizard from the above...and go step by step
through
the prompts.

select "Form Wizard", and then "ok"

This doesn't work for my query.

I have two tables.

Tab_1 with columns KEY, A, B, C
Tab_2 with columns FKey, D, E, F

My query is :

select A, D, E, F from Tab_1, Tab_2 where FKey = Key


When I create a form either by Autoform tabular, or with the form wizard
I get an outer form and an inner form.

The outer form selects a particular value for A
The subform shows a list of D, E, F for all rows
joined to that particular value of A

What I want is to show A, B, C, D in a single table.
 
This doesn't work for my query.
I have two tables.

Tab_1 with columns KEY, A, B, C
Tab_2 with columns FKey, D, E, F

Ok, obviously we needed a few more details. (eg: you got two tables).

There it two easy approaches here.

First, you can still use the wizard.

So, we are going to still assume you got the query built.

select new form

form wizard

Also, select the query in the "choose table/query" combo box

now, click ok, and you get to choose the fields you want from your query....

(select the fields you want for the form).

next.....

here you get a choice that allows you to build either two forms, or one
form. In the "how do you want to view your data", choose the 2nd option, and
you should note that the right side shows a "single form" now. (try
selecting either one...see how it changes).

Choose next....

Here we choose tabular....

next.....

You choose you "style"

and you can hit finish.

At this point you will have a single continues form.

However, do note that you do NOT have to use the wizard here, and you can
just create a blank form, and set the data source of that form in the
properties sheet to your query, and then go view->field list. You can then
drag those fields from that list to the form. (and, you have to move things
around..and set the form to continues mode in the other tab).

In other words, if you can build a form without the wizard, then give that
try also, as that is USUALLY what I do. (I still use the wizard for a lot of
forms..but often for continues forms and only 3 or 4 fields, then it is such
little work to create a form, that I don't use the wizard.

However, try both approaches....

When I create a form either by Autoform tabular, or with the form wizard
I get an outer form and an inner form.

Yes, as mentioned, you are skipping, or not setting the correct option when
prompted for "how do you want to view your data".


--

Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
Back
Top