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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report using a Query by Form 1

Status
Not open for further replies.

nastar1

Technical User
Nov 1, 2005
122
US
The code below was clipped from Northwinds. When I run the report the form displays the single combo box. It allows me to select from the combo box and when I click the OK button, the main window for a report displays behind the still open Form and nothing happens beyond that.

All I can do at that point is click the Cancel button.

Any ideas where I may begin trying to determine the logic breakdown?


Private Sub Report_Open(Cancel As Integer)

' Open frmOrgLookup form.
' IsLoaded function (defined in Utility Functions module) determines
' if specified form is open.

Dim strDocName As String

strDocName = "frmOrgLookup_test"
' Set public variable to True so Sales by Year Dialog knows that report
' is in its Open event.
blnOpening = True

' Open form.
DoCmd.OpenForm strDocName, , , , , acDialog

' If frmOrgLookup form isn't loaded, don't preview or print report.
' (User clicked Cancel button on form.)
If IsLoaded(strDocName) = False Then Cancel = True

'Set public variable to False, signifying that Open event is finished.
blnOpening = False

End Sub
 
While I don't care for that method of filtering a report, I think there is code in the form or report to make the form invisible or close it.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
dhookom,

What method of filtering a report do you prefer? I'm just looking for a more intuitive method for the user to enter report filter criteria.

Thanks
 
I always start with a form open with controls to allow filtering the report. Then I use code to open the report like:
Code:
  Dim strWhere as String
  Dim strDoc as String
  strDoc = "rptYourReportName"
  strWhere = "1=1 "
  If Not IsNull(Me.txtStart) Then
    strWhere = strWhere & "And [DateField]>=#" & _
      Me.txtStart & "# "
  End If
  If Not IsNull(Me.txtEnd) Then
    strWhere = strWhere & "And [DateField]<=#" & _
      Me.txtEnd & "# "
  End If
  DoCmd.OpenReport strDoc, acPreview, , strWhere

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top