Home » Developer & Programmer » Forms » programmatically filling a form field? (Forms, 6i, Windows 7)
programmatically filling a form field? [message #536202] Mon, 19 December 2011 14:01 Go to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I have a form that contains a button. When a user highlights a record in a multi-record block and clicks a "Show Detail" button I save the value of the highlighted record to a global variable. I then show another form using call_form.

The receiving form is put into query mode. All I want to do is fill a field in with the passed parameter that was set in the calling form. I cannot get the parameter to show up until I exit query mode. I don't understand why this is, I simply want to fill in the field value and that's it. I want the user to add more information to the form so they can refine the query. Then execute the query manually.

How can I fill in the form field? I have tried so many different ways. :BLOCK.ITEM := value, etc.

I know this seems quite simple but I just cannot get it to work.

Thanks!
Re: programmatically filling a form field? [message #536205 is a reply to message #536202] Mon, 19 December 2011 14:28 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
The receiving form is put into query mode.

That might be a culprit. Once you enter query mode, form waits for you to enter search criteria and execute query. It does nothing in between.

However, as you simply want to execute query based on a value passed through a global variable, there are a few options available. One of them is to use PRE-QUERY trigger as
:block.search_item := :global.variable_name;
and - in WHEN-NEW-FORM-INSTANCE trigger
execute_query;


Another one is to set search criteria with SET_BLOCK_PROPERTY, using its ONETIME_WHERE or DEFAULT_WHERE clause (they both might work the same way in your case). You'd write a WHEN-NEW-FORM-INSTANCE trigger as
set_block_property('block', onetime_where, 'search_item = :global.variable_name');
execute_query;


P.S. Forgot to mention: global variables are of CHARACTER datatype. Note that you might need to perform data conversion in order to get correct result. Consider using parameters instead.

[Updated on: Mon, 19 December 2011 14:29]

Report message to a moderator

Re: programmatically filling a form field? [message #536211 is a reply to message #536205] Mon, 19 December 2011 14:56 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
Thanks. This has shed some light on the issue I am having. I actually tried the first method you outlined (pre-query trigger). It works in that it DOES pull back the correct information for the passed in GLOBAL parameter. The issue is that all I want to do is take the passed in value and fill in the correct field in the receiving form and NOT actually query the form. I want the user to see the passed in parameter in the form, the user will then have the option of whether they want to execute the query as is or if they want to fill in more fields thus refining the query.

I just cannot seem to find a way to fill in the form with the GLOBAL variable and then leave the form in query mode so the user can decide what to do next. Do this make sense?

Thanks again...
Re: programmatically filling a form field? [message #536215 is a reply to message #536211] Mon, 19 December 2011 15:07 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
OK, so do the first part of the story - either in PRE-QUERY or by SET_BLOCK_PROPERTY, just don't EXECUTE_QUERY.
Re: programmatically filling a form field? [message #536218 is a reply to message #536215] Mon, 19 December 2011 15:21 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I am trying to understand what you are saying. I want the user to SEE the value before the query is executed so they can choose to input more form fields or not. They will then have to execute the query manually. A pre-query trigger will not show the value until the query is executed.

Thanks...
Re: programmatically filling a form field? [message #536242 is a reply to message #536218] Tue, 20 December 2011 00:06 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, you could create a control block with an item that would display that value and say something like "If you don't enter any other criteria, you'll get results depending on this value".

Or, you could write user's manual saying that "when you push a button in the first form, current record's value will be passed to the second form. By default, executing a query in the second form will return results that depend on that value. If you want to refine search, enter some more values and then execute query."
Re: programmatically filling a form field? [message #536364 is a reply to message #536242] Tue, 20 December 2011 07:45 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
Thanks much for your help Littlefoot. I just wish that I could make the passed value appear in the text box before the query is executed. Is that just not possible?

It seems like no matter what I have tried I cannot get the passed value to appear in the correct form field until AFTER the query has been executed.

Thanks...
Re: programmatically filling a form field? [message #536379 is a reply to message #536364] Tue, 20 December 2011 10:02 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I got this working the way I wanted by creating and invisible display item and then setting the "Copy Value from Item" property for the field I wanted visible to this "dummy" field.

Thanks...
Re: programmatically filling a form field? [message #536385 is a reply to message #536379] Tue, 20 December 2011 11:13 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'm glad you made it work!

However, one step is missing here: I suppose you set that invisible item's value = global variable. What did you do then? Entered query mode and database item showed value based on invisible item's value?
Re: programmatically filling a form field? [message #536386 is a reply to message #536385] Tue, 20 December 2011 11:16 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
Sort of. After I set the invisible item's value I left the form in query mode so that the user could either fill in more fields and narrow their results OR they could just execute the query straight away with the passed value as the only parameter.

Thanks!
Re: programmatically filling a form field? [message #536387 is a reply to message #536386] Tue, 20 December 2011 11:18 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
After I set the invisible item's value I left the form in query mode

And at that point, value you passed is visible on the screen, in a database item?
Re: programmatically filling a form field? [message #536388 is a reply to message #536387] Tue, 20 December 2011 11:19 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
Correct. There is probably a much easier way to do this but I am fairly new to forms.
Re: programmatically filling a form field? [message #536389 is a reply to message #536388] Tue, 20 December 2011 11:21 Go to previous message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Thank you for the explanation!
Previous Topic: form6i
Next Topic: problem when i run form >> Error 404--Not Found
Goto Forum:
  


Current Time: Thu Jul 25 21:25:32 CDT 2024