Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Writing to Input Box

I would like to write data from tables to fields in an inout box. I have looked at the APIGuide but cannot get the syntax right to do this. What I am trying to do is the following:

I have an inout box where I list some variables. I have a list box which lists the weeks I have posted so far. When I choose a month and week I would like to write the data to the input box to avoid having to type out the values manually. An example is a multi box. When I select my month and week the Multi Box displays the values associated to my selection.

Can I use a Macro to do this or is there an easier way, I just need a value to be written to the input box because once the values are written I would like to change the amounts to update the records in the tables.

Is this possible?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I see...
You are copyng value from variable Month1 to variable Month. And you want to copy field Month to variable Month. So the line should be
month1.SetContent ActiveDocument.Evaluate("Month"), true
But here is another problem - you have a variable Month and a field Month, so evaluete doesn't know what to do. Apparently it uses variable and copies it to itself. Solution
1. Delete completely variable Month.
2. Create new variable, for example vMonth
3. Change the macro:


...
set month1 = ActiveDocument.Variables("vMonth")
...
month1.SetContent ActiveDocument.Evaluate("Month"), true


View solution in original post

7 Replies
Anonymous
Not applicable
Author

John,
Writing to a variable using API is not a problem. Maybe you don't need even this, just define the variable properly. What value you want to assign to the variable?
(Simple example, if it is Month that you want to assign to a variable, define the variable as
=Month)

Not applicable
Author

Hi Michael,

I have attached a .qvw file to explain my problem. I set my variables in the input box. What I need to happen is when I select month then Week I need the sum of the House and Food fields to be written to the input box. Reason is if I need to update historic records its a pain having to fill in all the details again when really all I want to do is update one field. If I want to update a historic record and don't pull in the correct quantties then all the firlds except the field I updated would be over written. Then the figures will be out and the data will be ruined.

I'm building a Budget application which is just about finished and this is the last little thing which is bugging me. Once it is done I'm planning on uploading it for everyone to use or extend.

John

Anonymous
Not applicable
Author

John,
I can't tell if I really understood what you want, and if it will help.... Anyway:
The input box Budget Information 1 is using variables House1 and Food 1 defined as sum of the appropriate fields. So, they change every time with selections.
The input box Budget Information 2 uses House2 and Food2, and they are assigned by a macro on button click. I enabled the button only if one month and one week is selected.
Hope it will help.

Not applicable
Author

HI Michael,

Thank you for your reply, I think this could work. I'll test it tonight with the document I have and get back to you.

Thank you for taking the time, looking at the marco I can now see where I was going wrong..

Cheers

Not applicable
Author

HI Michael,

I have changed the file now, have a look if you want. One thing now which I'm battling with is passing the Month across.

JOhn

Anonymous
Not applicable
Author

I see...
You are copyng value from variable Month1 to variable Month. And you want to copy field Month to variable Month. So the line should be
month1.SetContent ActiveDocument.Evaluate("Month"), true
But here is another problem - you have a variable Month and a field Month, so evaluete doesn't know what to do. Apparently it uses variable and copies it to itself. Solution
1. Delete completely variable Month.
2. Create new variable, for example vMonth
3. Change the macro:


...
set month1 = ActiveDocument.Variables("vMonth")
...
month1.SetContent ActiveDocument.Evaluate("Month"), true


Not applicable
Author

Hi Michael,

Thanks for the solution and for your help.

I'll be uploading the App sometime this week and I'll send you a copy.

Cheers,

JOhn