You may want to use the DataWindow's Query Mode as Terry mentioned. You will have to provide your user with instructions, but the basic use is to simply enter the values you want to match directly in the DataWindow. For more information see the topic Providing query ability to users in the DataWindow Programmer's Guide. Here is code I have in one of my utility windows. It uses a menu with a toolbar button to put the DataWindow in Query Mode and to turn Query Mode off and retrieve. I'm using PFC message routing between the menu and the DataWindow event but you could simply call the event from a button clicked event, in which case you'd remove the lines that modify the menu.
// this code is in an event in the DataWindow
// toggles query mode on and off
if "no" = object.dataWindow.queryMode then
// you may want to check for unsaved changes here and let the user go back
object.dataWindow.queryMode = "yes"
m_myMenu.m_rows.m_query.checked = TRUE // this has a button on the toolbar
else
m_myMenu.m_rows.m_query.checked = FALSE
acceptText()
object.dataWindow.queryMode = "no"
retrieve()
end if
To get maximum flexibility set criteria.override_edit='yes' on some or all of the columns. The code below sets criteria.override_edit='yes' on all the columns. This may not be appropriate for your situation. Without override_edit the user is restricted to entering query values that pass the column validation.
// this code is in an event in the DataWindow
// it is called after the DataObject is set
// it sets criteria.override_edit='yes' for all the columns
string ls_describe, ls_modify, ls_col, ls_result
integer li_colCount, li_col
setTransObject(SQLCA)
ls_describe = "datawindow.column.count"
ls_result = dw_1.describe(ls_describe)
if not isnumber(ls_result) then
// logging code elided
ls_result = '0'
end if
li_colCount = integer(ls_result)
for li_col = li_colCount to 1 step -1
ls_col = "#" + string(li_col)
ls_modify = ls_col + ".criteria.override_edit='yes'"
ls_result = dw_1.modify(ls_modify)
if "" <> ls_result then
// every column may not have an edit, and some edits might not // have the property. it's just as fast to try to modify it as it
// is to check it
// logging code elided
end if
next