Setting a Field's Control Source as a Variable

JustinS

Member
Local time
Today, 04:15
Joined
Apr 11, 2020
Messages
58
See attached picture. I have to set up a bunch of reports which will have some varying data fields. I will be using filter forms that allow the user to select what they want to view in the report. Once the desired information is selected the report is filtered via a where clause.

My question is whether there is a way to set the control source for the fields that I want to filter on up as variables? I didn't see anything in google on this subject. Thanks in advance for any help you guys can provide me with.

Variable.PNG
 
Hi. You could try concatenation. For example:

strWhere = strWhere & " [" & FieldNameVariable & "] >=" & Me.txtValueMin & " AND "
 
If I understand correctly, you want to set the control source of a textbox to a different field dynamically? You might look at dynamic crosstab reports, where the fields vary. A line of code might look like:

Me.TextboxName.ControlSource = strName

Letting the user select the fields can be messy, since you may have issues with textbox sizes being inappropriate to the data selected.
 
If I understand correctly, you want to set the control source of a textbox to a different field dynamically? You might look at dynamic crosstab reports, where the fields vary. A line of code might look like:

Me.TextboxName.ControlSource = strName

Letting the user select the fields can be messy, since you may have issues with textbox sizes being inappropriate to the data selected.
Oh, oops, sorry if I misunderstood the question. Cheers!
 
Actually @theDBguy was correct on what I was looking for. I was trying to make the field to be filtered on in the report variable. The suggestion worked.

Thanks.
 
Not my first misinterpretation, not likely my last. ;)

I guess you mentioning control sources and this:

allow the user to select what they want to view in the report

Which I thought meant they were choosing which fields they wanted to see on the report, not what they were filtering on. Glad dbGuy nailed it for you.
 
Actually @theDBguy was correct on what I was looking for. I was trying to make the field to be filtered on in the report variable. The suggestion worked.

Thanks.
Hi. Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom