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

Assign value to variable in report

Status
Not open for further replies.

Chew407

Technical User
Mar 28, 2005
92
CA
Is it possible to assign a value to a variable in a report upon opening a report? My problem is that some numbers are being double counted because within the SQL i'm using they exist twice in a related table. I want to take the single number and make calculations with it. Anyone understand what I am trying to achieve? Any help you can provide is much appreciated.

Chew
 
hmmm...maybe you have a different issue. Could you GROUP on the item and do a calculation in the Item Header? Maybe i'm completely missing the point...give us some more details.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Chew
Well, you can assign a value to a text box upon opening a report.

Say that in the Report Header there is a text box called [txtWhatever]. Then you include code to indicate what will go in that text box.
Normally, that would go in the Format event of the Report Header. Something like...
Code:
Dim txtTemp as string
If "whatever field you expect the data to come from" = 4
txtTemp = 4
Else txtTemp = 3
End If
txtWhatever = txtTemp

Do you have a way of determining what will be fed to that text box?

Are we still dealing with the same "duplicate values" issue you were trying to sort through a week or two ago?

All the best.

Tom
 
Not sure what you mean about the double counting problem. It would seem that you might not be normalized. However, the module associated with a form or report is a class module like any other class module. So in your reports module you can simply declare a public variable

Public myVariable as variableType (string, integer, object, etc.)

When you open the report from another source set the variable

reports("myReport").myVariable = theValue

You could use let, get, set methods as well.
 
GingerR, I tried grouping but the problem still occured.

Hey Tom. Yup, same problem. Unfortunately other projects came up and I was unable to finish this one. I tried sending the code but hotmail wouldn't allow me to send it... something about it containing a virus. I assure you it didn't but I gave up. I may try sending it from gmail.

Thanks MajP. I'm willing to try anything at this point.

Chew
 
Chew,
Here is a good examples of what I am talking about. I built a pop up form (frmPopUpCalendar) that has a calendar control on it. On this form I have a public variable

Public cntrlCallingControl as control

So basically "cntrlCallingControl" is now a property of the pop up form.
Now from anyform in the db that has a date field I set up the double click event to pop up the calendar form. The date field textBox calls the pop up form so I refer to that control as the "Calling Control". In the double click event I set the "Calling Control" of the pop up form

Set forms("frmPopUpCalendar").cntrlCallingControl = me.aDateFielTextBox

The code on the pop up forms sets the calendar controls control source to the forms "cntrlCallingControl" property.
 
What exactly do you want to do with a "variable"?

What's your table structure and report's recordsource? How is it reporting "wrong" for you, and how do you want it reported?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top