Form Passing parameters to query

S

snowiii

I have a form that has two combo boxes and one text box that the user either
selects the appropriate value (combo boxes) or enters text. The form is
opened when the report it is linked with (vb code to fire off on open) is
invoked and the fields in the form are in the criteria field in the query
that feeds the report.

My issue is that it appears the form data is not making it to the query. I
say that because when I run the query by itself and type in the appropriate
values in the parameter boxes that it prompts the user for, I get my data.
When I open the report and the form opens and I select the same values that I
just typed into the query, the report comes back with no data.

I used the below vb code in another database and have no problems with it
returning expected values..In the newer database it is not returning any
values...

Kewpie doll to anyone who can help me with this.... :-}

Here is the vb code for the form including with code for the "Ok" button
that I click once all the field values are selected:

Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
' If we're not called from the report
MsgBox "For use from the MBB Report only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
_________
Private Sub OK_Click()
Me.Visible = False
End Sub
______

Here is the VB Code for the Report upon opening:

Option Compare Database
Option Explicit
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
DoCmd.Close acForm, "MBB Dialog"
End Sub

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 Sales By Category Dialog
DoCmd.OpenForm "MBB Dialog", , , , , acDialog, "MBB Report"

' Cancel Report if User Clicked the Cancel Button
If IsLoaded("MBB Dialog") = False Then Cancel = True

' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False

End Sub
 

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

Top