Question:

Access: Passing the value of a form control to a report

by  |  earlier

0 LIKES UnLike

Okay, I am building a form in Access for running reports based on their selections...

I have it so the user can select various options and then the report is created using a dynamic query (based on their selection). I am running into a problem when I select a value from a combo box and click the command button to view the report.

The combo box on the report form is called poSelect. It lets them select a specific Purchase Order number. Each purchase order is assigned a autonumber ID which I am using as the PK.

In my report Load event, I have this:

' If they choose to select a purchase order, determine which PO was selected.

If rptOption = 2 Then

  Dim PO As Integer

    PO = [Forms]![frmReports].[poSelect]

End If

--------------------------

You'd think that this is a pretty straight forward command which places the value of the poSelect control into a varible named 'PO' so that I can use it in a query...however, every time I attempt to pull the report it asks me to input the value of the variable PO before the report will run.

How can I pass the value of poSelect on my form to the PO variable on my report?

 Tags:

   Report

1 ANSWERS


  1. I'm not a guru in VBA, but since you've instantiated your PO variable in your IF clause, wouldn't the scope of your PO variable be only WITHING the IF??

    If so, try declaring the variable outside...

    Another question: in the frmReports form open when you run this?

    Hope this helps! Good luck!

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.