Passing parameters to VFP 9 form - forms

I have a form in VFP 9 that is usually called from another form with 2 parameters.
I've got a strange thing happening: when I execute DO FORM jobless_add in command window, the first parameter is always set to "2", while no parameters were added.
As a result, I have EMPTY(par1) == false and EMPTY(par2) == true. After that I've tried to open the form in the normal way (from the other form's button click with 2 parameters) and I've gotten this result in debugger
This is my first visit, so I cant insert images. Link: image
(hint: Locals: all ok, Watches: "2" again)
NOTE: I have no global variables yet.

You most likely have a table with a field/column called 'jobless_id'.
To clarify further, a table's field takes precedence over a memory variable if you reference just the unqualified field name. Try "m.jobless_id" to explicitly reference the variable (i.e., the parameter).

Related

MS Access: Enter a specific text in a form using command button from another form

I would like to ask for your help on the following issue in MS Access.
I had created a form "CustomerListF", filled with command buttons for each client. For each button, I had created the following code:
Private Sub cmd_outlets_ABC_Click()
DoCmd.OpenForm "OrderFormF"
Forms!OrderFormF!Outlets = "ABC"
End Sub
The button would then open another form "OrderFormF" and enter "ABC" in the textbox named "Outlets". However, I realized the second line of code (Forms!OrderFormF!Outlets = "ABC") would always create a phantom record in my subform, which is located in "OrderFormF", and this record would travel to other clients' forms. This phantom record is usually created when the commandbutton is clicked twice (double clicks or subsequent clicks). It is a headache when the record starts to shift around.
enter image description here
I would like to seek your advice for vba code to edit the second line of code.
Thank you.
This approach for filling the field in opened form is not good. OrderFormF initialization and second line of your code with assigning value to the field may be executed in different sequence, they are not synchronized.
In order to avoid this, you should pass the argument to OrderFormF by another way. I would recommend to use OpenArgs parameter:
DoCmd.OpenForm "OrderFormF",,,,,,"ABC"
And then in Load event of OrderFormF assign the value to textbox:
Me.Outlets = Me.OpenArgs
In this case the "ABC" value will be assigned to first row in the form or to new record, if form is empty. Before assigning you can select the row if you need to assign value not to the first row. Also this way will protect you against double click on button, Load event executed only once during first form opening

JsViews/JsRender temporary/contextual helper variable in for loop

I'm trying to store a temporary/contextual variable in a for loop for later use inside another for loop. I used http://borismoore.github.io/jsrender/demos/step-by-step/11_accessing-parent-data.html as a reference.
{^{for instances ~templateId=templateId}}
{{:~templateId}}
<select data-link="templateId" class="selected-visible" name="select-template">
{^{for ~root.templates}}
<option data-link="{:name} value{:id} selected{:id == ~templateId}"></option>
{{/for}}
</select>
{{/for}}
Each data object in the instances array has a templateId property that is set to a certain value and each object in the templates array has an id property.
The first problem is that my debug {{:~templateId}} is not showing up. It seems the variable is not assigned.
After only using the ~helper set within the template markup, I have tried explicitly defining the helper in my "viewmodel" with
$.views.helpers({templateId: 0});
Now the value gets printed when I do not set it in the for loop, but when I set it in the for loop it disappears again.
The next problem might be that the ~templateId helper is not available in a ~root-scoped for loop, because the helper should only be available in child views of the instances loop?
The ultimate goal is to select the correct value in the select, so if other solutions are available, please do tell.
You need to remove ~templateId=templateId from your template...
Explanation:
The syntax ~helper is used to access helpers/contextual parameters, which can be either be passed in/registered externally, as shown here http://www.jsviews.com/#helpers, or can be created/set within a template, as in the example you linked to {{for movies ~theater=theater}} , or in this one: ~frstNm=firstName: http://www.jsviews.com/#samples/jsr/paths.
So generally you will either pass a helper in, or create it within the template - not both.
In your example above you are first passing ~templateId in - as 0 - and then you are redefining it as a contextual parameter, using ~templateId=templateId (which is actually setting its value to undefined, since ...=templateId sets it to the value of the templateId property of the current data - undefined, in your case).

Ligthswitch 2013 Set value ACB when launching from another screen

I have a search screen called TimesheetsByjob. This is based on a query called TSByJob and has one parameter called JobID. Normally the user will just open this screen and select a job. The ACB's JobID field is bound to the query parameter JobID.
I now want to add a button in the timesheet entry form to open this search screen from a button. Obviously, I know what the JobID is, so I want to (and the user will expect me to) preset the JobID instead of them having to select it from the ACB.
In the timesheet entry form my button as this is the Execute code:
int JobID = TimesheetProperty.Job.ID;
Application.Current.ShowSearchTSByJob();
I want to pass a param, but the method doesn't expect one.
Is there a way to overload the method to accept a param (if so where would I do that), or is there another way to do it other than making a 100% duplicate of the search screen and using a local property?
Regards
mark
In your SearchTSByJob screen, add a local property of the type you require. In that local property's Properties, check "Is Parameter".
Now you can pass a parameter to that screen. If you have multiple, Intellisense will tell you the order it expects.
int JobID = TimesheetProperty.Job.ID;
Application.Current.ShowSearchTSByJob(JobID);

Live search combo in Ext JS 4.2.2

I'm trying to implement a live search combo. It suppose to work like this:
When I enter a character into the combo field I read the current value and send it as a parameter to the store's url. In the backend the parameter is used to return any value from the database that contains it, so the store behind the combo gets filled only with those filtered values.
As I continue to enter characters into the combo, the parameter should be updated and sent again to the backend and so on, getting like this a smaller and smaller store.
I tryied to achieve this behaviour using the combo's event keypress, even keyup, but the problem is it's impossible for me to get access to the current value from the combo field.
For example, when I entered the "for" string into the combo, how can I obtain this value using the combo object? comboName.getValue() doesn't work, it returns nothing "".
I already saw the live combo example here: http://docs.sencha.com/extjs/4.2.2/#!/example/form/forum-search.html but doesnt help me at all.
So my big question is: how do i get the current value while still editing the combo's field?
Any help would be appreciated, thanks.
You should be able to use
comboName.getValue();
or
comboName.getRawValue();
Where comboName is your combo box. Are neither working- I note in your post you state getValues() which is an improper method. You may want to also check whether when you're referring to your combo box object, that the reference is actually correct. The first argument from the key events is actually the object itself, so you should be able to do, e.g.
listeners:{
keyup:function(comboBox){
var value = comboBox.getValue() || comboBox.getRawValue();
console.log(value);
}
}
Swapping you the value getting method as appropriate.
I found that the combo already has a quick search behaviour, I just have to set queryMode on 'remote' and some other small configurations. More details here:
Ext Js 4.2.2 combobox queryMode

Parameter Field issue

I am having a problem with one of my parameter fields. I have YES to show all the results with yes on, and NO for all of those with no on, on other parameter fields if i leave the field as "..." it will show both yes and no. I don't seem to be able to select "..." as a default value. When i click "..." in the parameter field no results are shown.
please see the below screenshots relevant to this column:
Image 1
Image 2
Image 3
Image 4
If you require any more information, please ask.
thank you,
'...' isn't a value that can be set. It is what is displayed when a value hasn't been chosen.
You can either:
make it an optional parameter; see Conditionally prompting for optional parameters
make it a multi-select parameter and look for the presence of one or the other or both
In both cases, it would be easier for you if you used a Boolean parameter rather than a String.