select query for continuous form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to make a querry to select records filtered on my continuous form. By
using the below code I get only first one of them (or the one the cursor is
on at a time).
How can I get all records which I view on my form?
Please somebody help me!

SELECT Codes.ID, Codes.DocNo, Codes.Year, Codes.Originator, Codes.Name,
Codes.OnServer, Codes.Link2Document, Codes.CopyOnCDs, Codes.PaperCopy,
Codes.Location, Codes.NoOfCopies, Codes.Selected, Codes.CD1
FROM Codes
WHERE ((Codes.ID=Forms!Main.ID));

Thank you.
Lana
 
Is your "continuous forms" form actually a subform of another form? If so, on
what basis are the two forms linked.

What happens when you remove the WHERE clause. Does that help? It will
return everything in the Codes table.
 
Why don't you create a query based on the record source of the continuous
form, that way you will get the same records in the form and in the query.
 
Hi GPO

My continuous form doesnt have any subforms and is not a subform itself.

When i remove the WHERE clause I get all the records from my table - which
is not what i want.

i want to be able to select the records which i see on the form after
applying a filter: 9 out of 350 for example (and i have many different
filters which return different results).

Does anybody know how to achieve that?

Lana
 
I want to create a query for printing the records which I have filtered out
on my form.
I have 6 filters. want only 1 standard report for printing results.
anybody can help?
Lana
 
You can create a query, empty one, and then assign the sql to it using code.
Create a function, before opening the report run the function, and then
reate the report based on this empty query that is not empty any more

Function AssignStringToQuery()
Dim DBS As Database
Dim rst As Recordset, SqlStr As String

Set DBS = CodeDb
SqlStr = "SELECT * FROM MyQueryNameUsedInTheForm Where " &
Forms![FormName].Filter

DBS.QueryDefs("QueryName").SQL = SqlStr
End Function
 
Back
Top