Archimede
Archimede

Reputation: 727

Access and VBA: change report text from report code

in my Access application I have a form and a report. In the form I have my textBoxForm, in the report I have my textBoxReport. Normally, in the textBoxReport I see the textBoxForm value. How can I set dynamically from the report VBA-code the value of the textReport? For example, I want that, if the value in the textForm is 1, the value in the textReport is "ok".

I have already searched a solution in internet, but in all cases I see always an error similar to 'impossible set this value for this element'.

Thank you!

Upvotes: 0

Views: 258

Answers (1)

Wayne G. Dunn
Wayne G. Dunn

Reputation: 4312

Does your report use a query? If so, you would just place an 'IIF' in the query that tests for the value you want to change, then either changes it to something else, or retains the original value. The below will test field 'Nbr1' for the presence of a 1, and if found, change it to 'OK', otherwise it stays the same.

Note! You will need to change the control source in the report to reflect the name you provide (i.e. 'MyChange') because you can't keep the original name.

SELECT Table1.ID, Table1.EMPID, Table1.TestResult, 
   IIf([Nbr1]=1,"OK",[Nbr1]) AS MyChange, Table1.Nbr2
   FROM Table1;

Upvotes: 1

Related Questions