I am trying to debug a form window written in VB6. It is to enter customer data so you can type in an address in the address field. You can also type in something like 90210 Main Street and on enter it will automatically parse the text and write the 90210 in the postal code field below and let Main Street be in the address field. It however can occasionally parse it wrong, which is what I am trying to fix.
The problem is that I can't figure out how exactly it is set up. If I type something into the TextBox address field and do a
?ADDRESS.text
In the immediate window, the it returns an empty string. There is also only a single function defined when I look in the dropdown list under the form. But when I set a breakpoint at it and click the textbox, then it doesn't break. It is the GotFocus() event:
Private Sub ADDRESS_GotFocus()
Call GCui.BM(ADDRESS)
End Sub
It's the same with the POSTALCODE textbox. It has DblClick, GotFocus and LostFocus event functions defined. But setting a break point in either one of them has no effect.
Is there any way of finding out where in the form the value Main Street or 90210 is stored? They are clearly visible in the ADDRESS textbox and the POSTALCODE textbox, but the immediate window returns an empty line when asking for their values.
Update 1:
It seems that someone has decided to completely rebuild the form with new controls. It probably happens in form.load. But I would still like to know if there is a way to search through variable values to find the string "Main Street" or "90210".
Update 2:
It turns out that there are two frames on top of each other. The top frame is hidden at startup and the bottom (almost identical frame with same labels and controls) are shown.
You can use the "Watch" feature. This will let you inspect all the properties of a form and all controls within the form and their values (look at the controls node).
You can also do this via code by looping over the form.controls collection.
Dim o As Object
For Each o In Me.Controls
If TypeOf o Is TextBox Then
Debug.Print o.Text
End If
Next
Related
I need to open a second form and position it in a particular location on the first form opened.
Explain: I added a panel to the original form and as I was putting controls on it, I got a message that I could not add any more controls. So...
There is an existing panel that I need to cover up with a second form and have it remain covered even if the original form is dragged about the screen. The second form will cover it, but I need to know how to position it in reference to the first form.
The only references I can find are how to position it on the screen, not another form.
There's certainly no easy way to do that (a form can't host another form). The limit you encountered was the max number of named controls you can have on a form (254, see https://msdn.microsoft.com/en-us/library/aa240865(v=VS.60).aspx).
However, a control array only counts once to that limit. So instead of adding a new control (for instance text boxes) for every input field, add them as new elements of a text box array. The difference in code is that you'll reference the text boxes by index instead of unique name (you can use constants as index parameters to identify the different input fields, such as name, address, etc).
I have a master form that calls a form called freight.
This freight form has all properties set to default except Caption, Name and window type which is 1-Modal.
The only method with code is the init which has:
select FRT1
The only object on the form is a command button with this in the click method:
messagebox(alias())
thisform.release()
So I would expect when I press the command button, the messagebox would say [FRT1] but instead it gives another alias from the master form.
Before the form is called from the master form, the alias is also explicitly set to FRT1
select FRT1
do form freight
Because the Freight form is modal, I would expect nothing in the master form to affect the data areas while the Freight form is running.
Since there is practically nothing in the Freight form, the problem would seem to be in the master form.
This errant behavior seems to only occur if the freight form is called from a button within a grid. Any ideas on what is happening or how to prevent it?
Aren't there any controls on the called form (typically a grid) that gets the focus and hence implicitly cause a change to current workarea?
BTW, I suggest using private data session and keeping each session separate.
Just a few thoughts.
I would open your debugger and put a
SET STEP ON
immediately before doing the
SELECT FRT1
DO FORM FREIGHT
Then, in the debugger, go to the "Watch" window and enter the value
ALIAS()
as the value to watch and to a click in the left-bar to show the red dot to STOP when it changes.
Just a thought of expectation. Your "Freight" form has its "DataSession" property to "1-Default data session", and if so, it is looking at whatever alias is in the DEFAULT session and not a PRIVATE data session that your master form may have...
I have seen this only EXTREMELY RARE cases ( 2 times ever in the 25+ yrs of working with FoxBase, FoxPro, VFP). In these cases, I had to EXPLICITLY do a select of the table TWICE in a row.
SELECT FRT1
SELECT FRT1
or even putting a bogus statement in between such as
SELECT FRT1
tmpXXXXXX = alias()
SELECT FRT1
Check with breakpoint and see if that works.
Only one other breakpoint I would TRY to do... put "PROGRAM()" in the watch window. Is it possibly calling some other derived class script you did not know about... or in the "DataEnvironment" of the form running code such as in the "BeforeOpenTables" event? Better to KNOW where its doing things than bypass
I want to create a dynamic action, that will set a value to an item on the page, when the value of another item (autocomplete text field) is set.
So the proccess goes like this:
Click on the autocomplete field
type some letters
choose one of the suggested values
I cannot find an event that will be executed when the selection of one of the suggested values happens. This way, I cannot see how I can read the value of the autocomplete field, once a suggested value is selected.
The change event doesn't fit my needs, it doesn't execute when one suggested value is selected.
I had the same problem, found this link: https://community.oracle.com/thread/2130716?tstart=0 and modified my dynamic action as follows to get the desired behaviour:
Event = Custom
Custom Event = result
From the link:
the problem seems to be the default behavior of the browser. When you
enter some text into the autocomplete and the list is displayed, the
focus is still in the text field. Also if you use the keyboard cursors
to pick an entry the focus will still be in the textfield. That's why
the change event of the textfield doesn't fire. It only fires if you
leave the field.
On the other side if you pick an entry with the mouse, the browser
will remove the focus from the text field for a moment (before the
JavaScript code puts the focus back), because you clicked outside of
the field. But that's enough so that the browser fires the change
event.
I had a look into documentation of the underlaying jQuery Autocomplete
widget
(http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) and
there is actually an event called "result" which can be captures if an
entry is selected from the drop down list.
Try "Lose Focus" as event. It will trigger your dynamic action when you leave the autocomplete field, i.e. your curosr is moved to another field.
This probably depends on the APEX version you are using.
In case of 18.2, because the underlying component is based on Oracle JET's "inputSearch" component, you need to use following configure to capture the select change event for text with autocomplete:
event: Custom
custom event: ojupdate
Reference:
https://docs.oracle.com/cd/E87657_01/jet/reference-jet/oj.ojInputSearch.html#event:optionChange
I turned on the browser console, then turned ApEx Developer toolbar debug, and found that, on the contrary, the "Change" event does fire upon user clicking with the mouse on one of the selections. However if the user uses keyboard (type a few letters to narrow the list down, then use down arrow key to arrive at desired value, then press enter) then the Change event does not fire, just as you say.
Moreover: even when you do get the value sent back via mouse-click initiated Change event, the value isn't the autocomplete's complete and valid value, but instead the possibly partial and wrong-case value just as typed by the user. I.e., the the change event's submission of the value precedes the autocomplete's substitution.
The answer that #VincentDeelen gave is the best alternative that I can see, although it doesn't quite give that "instantantenous synchronicity" feel. You could maybe use the "Key Down" event, but be careful with that. You could get a really excessive amount of web and db traffic as each and every keystroke (including corrections) results in another firing of the dynamic action.
Testing environment: ApEx 4.2.3 with Chrome 33 as well as IE 9.
p.s. This might be worth a mention to the ApEx development team as well.
It's not really ideal, but you could use onfocus(). I'm looking for the same thing you are, I think, a custom event that fires when the selection of a suggested value happens. I haven't found it yet though and that is my work-around for now. It will run whatever function you've created for this initially with no value, but once the selection is made it will return focus and run the function again with the right value. Like I said, not ideal but it works.
Jeffrey Kemp is right. You can set it up through a dynamic action using the custom event, result. You can also register it on page load using document.getElementById("{id}").addEventListener("result", {function}); or $("#{id}").result( function( event, data, formatted ) { //something here });.
Oracle apex 19 now added a "component event" when you create a dynamic action called "Update [Text Field with autocomplete]" - this action is fired when you select a value from the list, but not when you leave the field (similar to adding the custom event "ojupdate").
So, I have an ActiveX ListBox control named ListBox1 on Sheet1 of my Excel Workbook. I enabled multiple selections on it.
I also put some code in the Sheet1 Object:
Private Sub ListBox1_Change()
Debug.Print "hello world"
End Sub
Now, if I select three values in my listbox, I see "Hello world" three times in my immediate window. So I guess the Change event triggers correctly.
When I select any cell on the same sheet where my listbox is, and I do something with it (e.g. I type "ABCDE" in it, or I press Delete) the selection I made in the listbox goes blank.
So if I had the first value in the list selected, and then I click cell "A1", type "Hello" in it and press Enter, the very moment I hit the key the first value is unselected from the listbox.
Why the hell is this? This is driving me crazy. Is the Listbox1_Change event not working properly?
It's funny though, because I don't see an extra "Hello world" in the immediate window, so I guess the event didn't actually trigger...
Any thought?
Bruder
As I mentioned earlier this is because the .Listfillrange for both the ListBox is resetting automatically.
You have specified a named range for your .Listfillrange and the formula for the named range is
For FiltroCliente
=IF(CollClientePicker<>1,OFFSET(DatiMaschera!$D$2,0,0,COUNTA(DatiMaschera!$D:$D)-1,1),"")
Now when you are making any change, Excel is re-calculating the named range because of which the .Listfillrange gets automatically updated.
Here is another way to check it.
Scroll your Listbox1 and select an item and then select an item in Listbox2. You will notice that the Listbox1 automatically scrolls to the top because it's .Listfillrange gets automatically updated.
SOLUTION
Instead of a Named Range in .Listfillrange, automatically fill the listbox using .Additem
SAMPLE CODE
'~~> Example : Add values from Cell A1:A10
For i = 1 To 10
ListBox1.AddItem Sheets("Sheet1").Range("A" & i).Value
Next i
HTH
Sid
Using autogenerated form from a single database table. The form uses the class WizBtns included in c:\Program Files\Microsoft Visual FoxPro 9\Wizards. The form has Top, Previous, Next and Bottom buttons.
Although the form only has textboxes to enter data for the fields in the table, I have added a custom Text Box from the toolbox which basically intends to display the sum of some fields. I have bound the ControlSource of the text box to a PUBLIC variable costTotal that is created on the form init.
Now the problem is updating the sum of fields in the text box, or simply updating value of costTotal. Where to add the code for this? Adding the code in the form's Refresh method mixes up the value of costTotal, when I press Next button to update all fields with new values, the custom text box displays the sum of the last record which is mysterious.
I would add a method to the form to do the calculation. Then, call that method from the Valid method of each of the textboxes involved in the calculation.
There is nothing wrong with using the refresh event to recalculate the values, just make sure that you call the refresh each time the record changes
If you are using navigation buttons to move between records then the click event of EACH button is an ideal place to issue the refresh request :-
Assuming the textbox is called txtSum and is located on the same form as the navigation buttons then in each buttons click event add this code
dodefualt()
with thisform
.txtSum.refresh()
endwith
Couple of things:
1) do not use the wizards! Make your own base classes. Trying to figure out what the wizard classes do and how to add functionality will take more time that coding your own base classes. Also, the wizard generated code and classes must be at around 10/20 years old, much has changed since then (a polite way to say they suck).
2) Do not EVER use public variables in FoxPro, except for maybe an app object.
If this is a one shot thing, just add default textboxes and buttons and design the form yourself. You will have total control and you will know what each thing does.