Change control source (1 Viewer)

FuzMic

DataBase Tinker
Local time
Today, 16:50
Joined
Sep 13, 2006
Messages
719
Hi guys

I want to change the ControlSource of a field in a report during opening of it but is not allowed in printPreview or after it is started.

How to work around this? Help please.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:50
Joined
Oct 29, 2018
Messages
21,467
Could you use an IIf() statement in the ControlSource or query column instead? Just a thought...
 

Micron

AWF VIP
Local time
Today, 04:50
Joined
Oct 20, 2018
Messages
3,478
what event did you attempt this in? Might have been the wrong one as I believe it's possible from Open event.
 

FuzMic

DataBase Tinker
Local time
Today, 16:50
Joined
Sep 13, 2006
Messages
719
It is done in open event, not much event choice, other is activate in which the same forbid
Iif not possible as i am relying on openargs to flag change
Thanks for trying
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:50
Joined
Oct 29, 2018
Messages
21,467
Iif not possible as i am relying on openargs to flag change
Thanks for trying
Are you sure? Have you tried? What happens if in the ControlSource you entered something like?
Code:
=[OpenArgs]
 

Micron

AWF VIP
Local time
Today, 04:50
Joined
Oct 20, 2018
Messages
3,478
maybe you should post calling code and open event code or a copy of db as I think it should work; or be certain that openArgs contains a value first.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:50
Joined
Sep 12, 2006
Messages
15,652
I would be surprised if you could change the control source after the report has assembled all the data.

Why do you need to do this? What is your circumstance?
 

Micron

AWF VIP
Local time
Today, 04:50
Joined
Oct 20, 2018
Messages
3,478
I would be surprised if you could change the control source after the report has assembled all the data.
That's just it. On Open, it has not done so.
as designed
rptCtlSrce0.jpg


as modified on open
rptCtlSrce1.jpg


It's not my report, btw. The db is from some other thread.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:50
Joined
Sep 12, 2006
Messages
15,652
Does anyone know what code is being used to change the source? Is the OP trying ot use a different field in the source query, or something else?

One way to do it would be to have a completely different source query, with the same field names, rather than change the source.

setting me.recordsource = "different query" will work in the open event.

I use this in reports to produce the same report, but with a slightly different query.

eg.
-select delivered dates, or invoiced dates
-select one branch or all branches
 

Micron

AWF VIP
Local time
Today, 04:50
Joined
Oct 20, 2018
Messages
3,478
Does anyone know what code is being used to change the source?
You mean with respect to the pics I posted?


Me.RequestName.ControlSource = "=[DsID]"
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:50
Joined
Sep 12, 2006
Messages
15,652
What is the purpose of showing a different value in "requestname"?

Could the OP not leave the control unbound, and just look it up from the tables at runtime in the detail print/format event, based on other data in the report?
 

Micron

AWF VIP
Local time
Today, 04:50
Joined
Oct 20, 2018
Messages
3,478
What is the purpose of showing a different value in "requestname"?
There is no point to that. It is a hack on a report in response to
I would be surprised if you could change the control source after the report has assembled all the data.
to which I replied with proof that control source can be modified on open. Don't try to rationalize the sense of what I posted from a data point of view. The message is just that it can be done in Open event.
 

FuzMic

DataBase Tinker
Local time
Today, 16:50
Joined
Sep 13, 2006
Messages
719
THANK YOU for all responses

As Macron rightly post, CHANGE of rowsource is possible.

SORRY i made the mistake of setting a sub report from main report & later make further settings in sub report.
Access already open sub report so further setting off sub is forbidden

A timing issie
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:50
Joined
Sep 12, 2006
Messages
15,652
@micron.

ah. OK - I thought you were talking about the specific issue, not in general terms. It's all sorted now, obviously.
 

Users who are viewing this thread

Top Bottom