Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem using code to open a form, but works to open a report

Problem using code to open a form, but works to open a report

Problem using code to open a form, but works to open a report

Hello: I would like to open different forms, based on dates in an unbound combo box on a different form. So, open a form to specify dates and then click to open a form with that date range of records. It is called from the form that is to open.
I currently used something I came across online, to open reports, but I can't seem to do the same thing with opening a form. What is in the following that is stopping it from working with opening a form? The result is that the it first opens the query specification. "enter Paramater Value", then opens the unbound form.

In Module:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?

Form where I choose dates on an unbound form:
Private Sub Form_Open(Cancel As Integer)

If Not bInReportOpenEvent Then
'If we're not called from the report
MsgBox "For use from the Statistics All Report only", vbOKOnly
Cancel = True
End If
Exit Sub
End Sub

On the report that I want to open:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True

' Open FrmCrosstab2
DoCmd.OpenForm "FrmStatsAll", , , , , acDialog
'If the user closed the form (cancelled)

If Not IsFormLoaded("FrmStatsAll") Then
Cancel = True
End If
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub

Thank you for any help. Sophia

RE: Problem using code to open a form, but works to open a report

I would add some debug.print statements and/or breakpoints in the code to see what is happening. FAQ705-7148: How to debug your code

Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close