REPORT

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

Guest

I have a list with 8 field in it..
This list box is then connected to a combo box by "select case" Statments
What I would like to do is have command button that regenerates a report
evertime
one of the fields on the list are selected, and then i want it filtered by
the value that is in the combo box..


PLease help.last peice of coding in long long long program
 
Here is a chunk of code I used before in a similar situation.
You have to open it up in design view, make changes to the report properties
(like the SQL) and then save changes and close before opening the
report....All from VBA code:

Dim stDocName, strOrder, strSQL As String
stDocName = "Report1"
strOrder = "field1, field2, field3"
strSQL = "SELECT * FROM table1"

'Open report in design view in order to change report properties
DoCmd.OpenReport stDocName, acViewDesign

'Set the report sort order, close and save the new settings
'then open the report
Reports!Report1.OrderBy = strOrder ' "field1, field2, field3"
Reports!Report1.OrderByOn = True
Reports!Report1.RecordSource = strSQL ' "SELECT * FROM table1"
DoCmd.Close acReport, stDocName, acSaveYes
On Error Resume Next
DoCmd.OpenReport stDocName, acPreview
If Err = 2501 Then 'No records found - msgbox displayed from report
Err.Clear
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "frmReportSelections", acNormal
Exit Sub
End If
On Error Goto 0


Hope this helps!



jmonty
 

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

Back
Top