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

Displaying variables pass from a form 1

Status
Not open for further replies.

mdweezer

Technical User
Jun 15, 2004
56
US
I have a form with a bunch of check boxes. Each check box is a certain criteria for a report, the user checks however many boxes they want and when they hit a comomand button it executes a report based on the criteria they selected.

However at the top of that report I would like to display the value of each check box they selected, so when someone looks at the report they can say "Ok, these records are dealing with this, that, and the oher thing"

How do I go about doing that?

Thanks!
 
Ok,
you can use OpenArgs to pass variables across forms or reports.

So in your form, you'd activate the report by something like:

if blah... then
docmd.openreport blah, blah, blah...
else
docmd.openreport blah, blah...
endif

well, what you need to do is to combine all the values of the chk boxes into a string, then pass it to a new report...

docmd.openreport blah, blah,,,, chk1 & "," chk2 & ","...

once this is done, in the onLoad event of your report, you would need to "get" the passed arguments:

dim str as string
str = me.OpenArgs

and then you need to "process the string", most likely with a split function...

and then display your conditions based on values from the split

 
Crowley16 - Do you know which version of Access first allowed for OpenArgs to be used with Reports?

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
When I have my string passed to the report, what is the propper syntax on the report to lay out where I want it displayed?

(report newbie here, sorry)
 
What version of Access are you using mdweezer?

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Access 2000 9.0.4402 SR-1

Current in the report code I am creating a SQL string which I then launch with me.recordsource = qry

I have a series of If statements, can I create my string of text that I want to be displayed at the same time? Or do I need to compile that on the form and pass it as an argument?
 
hmm, good question cajunCenturion...

I'm not too sure about that...

mdweezer,
on the report you would need to create some new tbx and set them to either disabled or not visible, one for each of your check boxes, and set them as unbound.

Then in the onLoad event of your report, assuming you've already split your string into it's various elements, you would have:

if criteria1 then
tbx1.enabled = true (use visible if you've set them as invisible)
endif
if criteria2 then
tbx2.enabled = true
endif
...
...
 
Setting them on the form and then making them visibile/invisible is a good idea... I think i'll give that run a try.

Thanks!
 
There is no way to disable them, I can make them not visible but in the code on the report lblWhatever.visible doesn't exist...
 
well, then don't use enabled=true/false...
just use visible=true/false
 
I have everything I need concatanated into a field type string called "list", now all I need to do is show the contents of that variable on my form when it loads.

Shouldn't this be simple? :)

I tried creating a unbound text box and for the OnOpen of the report saying txtFoo.value = List but that woudln't fly.

Any suggestions?
 
not quite that simple...

if you read my above post earlier again, u'll realise that the concatenated string wouldn't be much use because it's something like:
"0,-1,0,0,-1"
since access uses 0 and -1 for true and false.

what you need to do with this is to "split" the string using the split function, goto F1 for details on how to use, plus there's threads about it already.

Once you've split the string into either "0" or "-1" then you can use them to set the fields.

'split splits strings into an array, I'm assuming list is an array...
if list(0) then
lblCriteria.visible = true
else
lblCriteria.visible = false
endif

 
what I did was
Code:
if chkFoo.value = true then
list = "Product"
end if

etc etc...

So my string is full of text values and not the values returned from the checkbox. So right now I have a completed string exactly how I need it to be, I just need to display it now

However I work a 9 hour 4 day week with a half day friday so its time to go home and forget about this, i'll check back monday :) Have a good weekend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top