multiple search in dbf - visual-foxpro

When entering data in a text box, you must search by name, identify, address and telephone when clicking on the search button, but sometimes the search does not work well.
this is the button code:
SELECT clientes2
IF !EMPTY(THISFORM.Text1.Value)
GO TOP
SET ORDER TO
SET ORDER TO nombre
SEEK ALLTRIM(thisform.text1.Value)
thisform.Refresh
ENDIF
IF !EMPTY(THISFORM.Text1.Value)
GO TOP
SET ORDER TO
SET ORDER TO identifica
SEEK ALLTRIM(thisform.text1.Value)
thisform.Refresh
ENDIF
IF !EMPTY(THISFORM.Text1.Value)
GO TOP
SET ORDER TO
SET ORDER TO direccion
SEEK ALLTRIM(thisform.text1.Value)
thisform.Refresh
ENDIF
IF !EMPTY(THISFORM.Text1.Value)
GO TOP
SET ORDER TO
SET ORDER TO telefono
SEEK ALLTRIM(thisform.text1.Value)
thisform.Refresh
ENDIF

Related

How to change List Item value on WHEN_VALIDATE_ITEM

I am working on Forms 6i on a very old software.
There is a requirement to add 3 List Item (Combo Box) to the form.
If the value in List Item X is changed, then upon WHEN_VALIDATE_ITEM, I need to change the value on List Item Y.
Here is the code but it's not working.
BEGIN
IF :PIH.TEXT_ITEM1544='Book' THEN
Copy('Own Use',Name_In('PIH.TEXT_ITEM1546'));
END IF;
END;
There are no errors in compilation, but I believe that when I select the value Book and press enter or tab and go to another field, nothing is triggered.
Any help would be really appreciable.
What do you want to do exactly? If you want to assign the value 'Own Use' to the item PIH.TEXT_ITEM1546 you can do it with:
:PIH.TEXT_ITEM1546 := 'Own Use';
Or with:
Copy('Own Use','PIH.TEXT_ITEM1546')
The statement you're using:
Copy('Own Use',Name_In('PIH.TEXT_ITEM1546'));
is trying to copy the value 'Own Use' to the item referenced by PIH.TEXT_ITEM1546, i.e., it's trying to copy the value to an item named as the value stored in the item PIH.TEXT_ITEM1546.
The Name_In function gets the value of the specified item.

How to get record data from locate?

In VFP 6 I have a table called "cars" and inside a button I want to find an ID based on the name. What did I do wrong?
... code
SELECT cars
LOCATE FOR ALLTRIM(UPPER(name)) = variable_read_from_textbox
IF NOT FOUND()
messagebox("not found")
ELSE
messagebox(cars.id_car)
ENDIF
Running the code works ok when the name is not found but when it is found it errors out.
Thanks!
Your code is right in general. Slight modification for safety and fix for error:
SELECT cars
* this implies an exact match, regardless of set exact, and makes casing same
* remember this wouldn't use an index unless there is an index with the same signature
LOCATE FOR ALLTRIM(UPPER(name)) == ALLTRIM(UPPER(m.variable_read_from_textbox))
IF NOT FOUND()
messagebox("not found")
ELSE
messagebox(transform(cars.id_car))
ENDIF
As far as I remember, in VFP6, messagebox() was not yet capable transforming the value to string for you and expects a string (you didn't tell what the error is but that should be it).
A little caution about your search.
ALLTRIM(UPPER(name))
will NOT use an index, unless there is an index with key "ALLTRIM(UPPER(name))". If there is, it would be used, but such an index is actually useless because of the alltrim(). A better index would simply be:
Upper(name)
and then your search would look like:
variable_read_from_textbox = ALLTRIM(UPPER(m.variable_read_from_textbox))
SET EXACT ON
SELECT cars
LOCATE FOR UPPER(name) = m.variable_read_from_textbox
IF NOT FOUND()
...

Is it possible to display an Image in an autocompletion-popup list (Gtk3)

I am using an Entry with an EntryCompletion opbject that has a ListStore model.
For each record in the model, there is an image I would like to display in the autocomplete-popup list.
How can this be done?
Is it possible to add a Gtk.CellRendererPixbuf column to the model?
Interesting enough I could not find any examples of this yet it turns out to be possible and not insanely complicated. Lets start with a small image of the goal which uses icons for convinces reasons.
So how do we get there, first we create the ListStore containing a column with strings to match on and a icon-name to convert into a pixbuf (this could also be a pixbuf directly).
# Define the entries for the auto complete
entries = [
('revert', 'document-revert'),
('delete', 'edit-delete'),
('dev help', 'devhelp'),
]
# Setup the list store (Note that the data types should match those of the entries)
list_store = Gtk.ListStore(str, str)
# Fill the list store
for entry_pair in entries:
list_store.append(entry_pair)
Next step is setting up the EntryCompletion and linking it with the Liststore
# Create the Entry Completion and link it to the list store
completion = Gtk.EntryCompletion()
completion.set_model(list_store)
Now the magic, we need to create 2 renderers, one for the text, one for the pixbufs. We then pack these in the completion to add columns to it.
# Create renderer's for the pixbufs and text
image_renderer = Gtk.CellRendererPixbuf.new()
cell_renderer = Gtk.CellRendererText.new()
# Pack the columns in to the completion, in this case first the image then the string
completion.pack_start(image_renderer, True)
completion.pack_start(cell_renderer, True)
In order to make sure the renderers use the the correct column we here specify which column from the ListStore the renderers should read. For the image_renderer we set the icon_name attribute as we give it icon names. If we would feed it Pixbuf's we would need the pixbuf instead.
# Set up the renderer's such that the read the correct column
completion.add_attribute(image_renderer, "icon_name", 1)
completion.add_attribute(cell_renderer, "text", 0)
As there are no multiple column we need to tell the completion which column contains the string. In our case column 0.
# Tell the completion which column contains the strings to base the completion on
completion.props.text_column = 0
# Create the entry and link it to the completion
entry = Gtk.Entry()
entry.set_completion(completion)
And that's it!

unknown member or unable to edit control of grid's column on page frame

I've one grid created on second page of page frame and linked to .PRG file for each time activate on different page. Under Activate events, each grid's column defined its own member class created under .PRG file.The problem is I couldn't able to access to each member control of grid's columns even I tried to change it but it will remain same class created under individual page's activate events.
I won't initialise the gird's column control base class on grid's init event because I need to set additive access to different .PRG file When access on different page. This problem of failed to access column member or control of grid won't be exists in form when I initalised grid's member control under grid's init events. BTW,i'm using vfp 6.
My Code under Page item Activate Events
set procedure to
set procedure to cn_pro additive
for count = thisform.page_.pages(thisform.page_.activepage).grid_list.columncount to 1 step -1
column_ = "column" + alltrim(str(count))
thisform.page_.pages( thisform.page_.activepage ).grid_list.removeobject( "&column_")
next
with thisform.page_.pages(thisform.page_.activepage).grid_list
.addobject("column1","column")
.columns(1).visible = .t.
.columns(1).bound = .t.
.columns(1).width = 75
.columns(1).header1.alignment = 2
.columns(1).header1.caption = "Mod_Qty"
.columns(1).removeobject("text1")
.columns(1).addobject("btn_qty","btn_quan")
.columns(1).currentcontrol = "btn_qty"
.columns(1).btn_qty.visible = .t.
.columns(1).btn_qty.caption = "Mod Qty"
.columns(1).sparse = .f.
endwith
create cursor tmpcur(btn_qty logical null)
use in select('tmpcur')
use in dbf('tmpcur') in 0 again alias tmpcur_
use in tmpcur
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = ""
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = "tmpcur_"
thisform.page_.pages(thisform.page_.activepage).grid_list.refresh()
**My class code in cn_pro.PRG file(Same example 1 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages( frm_.page_.activepage ).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.column1.btn_qty.enabled = .f.
**=>It will return Error message said "unknown member btn_qty" How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
**My class code in cn_pro.PRG file(Same example 2 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages(frm_.page_.activepage).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.removeobject('column1')
**=>Remove entire column1 contained with** commandbutton "btn_qty"
.createobject('column1','column')
.column1.bound = .t.
.column1.text1.visible = .t.
.column1.sparse = .f.
.refresh()
**=> Previous CommandButton on column1 should be changed and
** replace with text here but It won't change and still be
** same commandbutton.Why, How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
Hopefully anyone could solve my problem here.Thanks!
If i understand correctly, your approach will not work. You don't need to remove columns, you need to add/remove objects to the column and then set the columns current control property to the control you want.
If you want a variety of different controls to display for the same column, then you set the dynamiccurrentcontrol property to an expression that will look at a value and then return the name of the column.control that you want to display dependent upon the logical comparison in the expression.
I think I've ready found the solution, the reason why it unable detect button(control members fo grid) because it is created right after return focus to main form when you have grid created on page frame.
m.result = .t.
frm_.page_.pages(frm_.page_.activepage).btn_print.setfocus() =>to set it focus for later trigger btn_print's gotfocus
=>event,which will be able to change property's of member control of grids.
this.release =>exit "frm" class
Coding for btn_print gotfocus
if m.result=.t.
m.result = .f.
with this.parent.gid_list
.columns(1).btn_qty.enabled = .f.
endwith
endif
Struggle me for one day more until i could find out the reason and solution.

Pentaho Report Designer 5.0.1 - Hide field with Empty field

I am using Pentaho report designer 5.0 CE.
My report is having two groups, and one group contains row band with elements and values like,
Group1
Group2
Label1 - Value1
Label2 - Value2
Label3 - Value3
...
I need to show a row only if the value is not empty(without leaving blank space).
I set the 'invisible-consumes-space' property to false (band level). The blank space is still there.
how could i hide a label & value (entire row) if the value is empty?
have you tried to put the label element and value element in a band. assumingly value is printed by name field.
this is your band.
-----------------
|label | name |
-----------------
select the band from structure tree and go to style tab->size&position -> visible option.
then open the expression tab and paste
=IF(ISBLANK([Name]);"False"; "True")
OR
=IF(LEN([Name])<=0;"False"; "True")
I use the one below to hide all the group headers & footers when there is no data.
set no data band -> hide-on-canvas option to false. Add a message
field and let's say 'No data available for selected date range'
And set all Report Header & Footer's visible option to:
=IF(ISEMPTYDATA();"False"; "True")
And it works.
Hope helps to you too.
And empty string is not the same as an invisible element. Use the "visible" style instead and add your formula to the band's "visible" style setting to hide the band and all its subbands.

Resources