Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ouputing SQL to a Report

Status
Not open for further replies.

Trudye

Programmer
Sep 4, 2001
932
US
Hi Everyone, I have written a SQL query but do not know how to execute it so that it outputs to a report. The SQL statment is behind a form that the user enters values into that determine what the report displays.

How can I get the output to display?

strSQl = "SELECT Clients.Active, Clients.Player, Deals.NContractStatus, " _
& "Deals.Company, Deals.[Deal Terms], Deals.Notes, Deals.ContractID, " _
& "Deals.From, Deals.To, Clients.Rep " _
& "FROM Clients INNER JOIN (Deals INNER JOIN [Deal Detail] ON Deals.DealID = [Deal Detail].DEALID) ON Clients.ID = Deals.ClientId " _
& "where clients.active = -1"

If Me!AllDates = -1 Then
Else
strSQl = strSQl & " AND Deals.From >= " & Me!FromDate
strSQl = strSQl & " AND Deals.To <= " & Me!ToDate
End If

If Me!AllStatus = -1 Then
Else
strSQl = strSQl & " AND Deals.NContractStatus between me!fromstatus AND me!tostatus "
End If

Thanx
Trudye
 
you need to create a report, and then bound that report to your query, or in your case, set the recordsource property of the report to your sql string...

the quickest and easiest way to do this is to use the create report wizard, and create a report based on some rough data, and then edit it to suit your query...

Then, when you activate your report, make sure you change the report's recordsource property to your sql string...

something like:

report_OnOpen()
me.recordsource = me.openargs
end

where open args contains the sql string...

Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top