I'm building a report based off of multiple queries, which uses a single combo box selection on a form.
One of the items I'm having trouble with is displaying a single dollar amount for a particular project selection. The project selection takes place on the above mentioned form.
I've approached this three ways so far.
1) I built a query which used the combo box selection as the criteria for the search to pull back the value I wanted. This worked.
I then tried to directly place the query into report by means of a subreport. The trouble is, that when I do this, the subreport asks for a parameter (the projectname) that should have been provided by the above query. The project names are very complex and I don't want the user to need to type it in every time they wish to look at the report.
2)I passed an integer using the open.report argument to my report then tried to use it as the text box control sourse.
On the form:
Private Sub Combo84_Click()
Dim comboselect As Integer
If Not IsNull(Me.Combo84) Then
comboselect = Me.Combo84
End If
End sub
Private Sub Command56_Click()
DoCmd.OpenReport "rptBudgetReport", acViewReport, "", "", , OpenArgs:="comboselect"
End sub
On the report in the textbox control source:
=DLookUp("[GMbudgetdollar]","[tblProjects]","[ID]=" & [comboselect])
When I run the report, the text box is filled with "#Name?"
3) I made a public variant called comboselect. The on-click event for the combo box (combo84) on the above mentioned form contains this code:
If Not IsNull(Me.Combo84) Then
comboselect = Me.Combo84
End If
This is meant to fill the comboselect with the ID number of the row I want.
Next, on the report, I created the text box (Text117) then went to the VBA for the report and made the following code.
Private Sub On_Load()
Dim GMDollarAmount As Currency
Dim GMtableLookup As Integer
'Uses the global variable Comboselect to pull the value of the combobox84 selection from the frmProjectSelector and use it to find the ID number of the field I want from the tblProjects
GMtableLookup = DLookup("[ID]", "tblProjects", "comboselect")
GMDollarAmount = DLookup("[GMbudgetdollar]", "tblProjects", "[ID]=" & [GMtableLookup])
Me.Text117 = GMDollarAmount
End Sub
However, on activation of the report, the text117 box remains empty.
Probably something very simple I am missing. Any help would be appreciated.
One of the items I'm having trouble with is displaying a single dollar amount for a particular project selection. The project selection takes place on the above mentioned form.
I've approached this three ways so far.
1) I built a query which used the combo box selection as the criteria for the search to pull back the value I wanted. This worked.
I then tried to directly place the query into report by means of a subreport. The trouble is, that when I do this, the subreport asks for a parameter (the projectname) that should have been provided by the above query. The project names are very complex and I don't want the user to need to type it in every time they wish to look at the report.
2)I passed an integer using the open.report argument to my report then tried to use it as the text box control sourse.
On the form:
Private Sub Combo84_Click()
Dim comboselect As Integer
If Not IsNull(Me.Combo84) Then
comboselect = Me.Combo84
End If
End sub
Private Sub Command56_Click()
DoCmd.OpenReport "rptBudgetReport", acViewReport, "", "", , OpenArgs:="comboselect"
End sub
On the report in the textbox control source:
=DLookUp("[GMbudgetdollar]","[tblProjects]","[ID]=" & [comboselect])
When I run the report, the text box is filled with "#Name?"
3) I made a public variant called comboselect. The on-click event for the combo box (combo84) on the above mentioned form contains this code:
If Not IsNull(Me.Combo84) Then
comboselect = Me.Combo84
End If
This is meant to fill the comboselect with the ID number of the row I want.
Next, on the report, I created the text box (Text117) then went to the VBA for the report and made the following code.
Private Sub On_Load()
Dim GMDollarAmount As Currency
Dim GMtableLookup As Integer
'Uses the global variable Comboselect to pull the value of the combobox84 selection from the frmProjectSelector and use it to find the ID number of the field I want from the tblProjects
GMtableLookup = DLookup("[ID]", "tblProjects", "comboselect")
GMDollarAmount = DLookup("[GMbudgetdollar]", "tblProjects", "[ID]=" & [GMtableLookup])
Me.Text117 = GMDollarAmount
End Sub
However, on activation of the report, the text117 box remains empty.
Probably something very simple I am missing. Any help would be appreciated.
Last edited: