But - hey! The darned thing works, now - do I want to fix what 'ain't broken? My daddy always said NO.
Okay - if you insist...here is the final code that works:
'Date Created: 23-May-2006 10:40:48 AM
'Last Updated: 24-May-2006 08:34:36 AM
'Created By : tuckerw
'Updated By : tuckerw
'Are there matching records present in the table?
dim global tbl as P
dim global qry as P
dim global nrecs as N
tbl = table.open("sites")
query.description = "Search for matching records"
query.order = ""
query.filter = "trim(Sites->Equake)=\"Y\""
query.options = ""
nrecs= a5_get_records_in_query("sites","equake=\"Y\"")
IF (nrecs = 0) then
qry.drop()
ui_msg_box("Null Query","There are no matching records in this search, unable to proceed" ,UI_INFORMATION_SYMBOL)
tbl.close()
end 'If there are no matching records, script ends here
else
'Close Quick Screen
DIM mode as c
mode = parentform.mode_get()
'If the form is in Enter or Change mode, first save the changes before closing the form
if mode = "ENTER" .or. mode = "CHANGE" then
parentform.commit()
'Check to see if the record was successfully saved
if parentform.mode_get()<>"VIEW" then
ui_msg_box("Unable to save your changes","Please correct and save, or discard your changes", UI_STOP_SYMBOL)
end
end if
end if
'Close the form
parentform.close(.f.)
'Opens sites and runs saved query on Equate
query.filter = "trim(Sites->Equake)=\"Y\""
query.order = ""
'Open the layout_type showing just the records that satisfy the filter
DIM Shared varP_Sites as P
DIM layout_name as c
layout_name = "Sites"
dim tempP as p
'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
'Test if pointer is valid
if is_object(tempP) then
'Test if pointer refers to a form or browse
if tempP.class() = "form" .or. tempP.class() = "browse" then
'Apply the query to the form or browse as the Base query. (this means that
'the user cannot turn the query off, only add to the query)
tempP.BaseQueryRun(query.filter,query.order)
'then activate the already open window
tempP.activate()
else
'Window is not already open, so open it
varP_Sites = :Form.viewqueried(layout_name,query.filter, query.order )
end if
else
varP_Sites_Plus = :Form.viewqueried(layout_name,query.filter, query.order )
end if
xbasic_wait_for_idle()
tbl.close()
end if
Now, if someone can figure out how to "nest" the queries - I'd be elated...
Thank you,
Wanda
Okay - if you insist...here is the final code that works:
'Date Created: 23-May-2006 10:40:48 AM
'Last Updated: 24-May-2006 08:34:36 AM
'Created By : tuckerw
'Updated By : tuckerw
'Are there matching records present in the table?
dim global tbl as P
dim global qry as P
dim global nrecs as N
tbl = table.open("sites")
query.description = "Search for matching records"
query.order = ""
query.filter = "trim(Sites->Equake)=\"Y\""
query.options = ""
nrecs= a5_get_records_in_query("sites","equake=\"Y\"")
IF (nrecs = 0) then
qry.drop()
ui_msg_box("Null Query","There are no matching records in this search, unable to proceed" ,UI_INFORMATION_SYMBOL)
tbl.close()
end 'If there are no matching records, script ends here
else
'Close Quick Screen
DIM mode as c
mode = parentform.mode_get()
'If the form is in Enter or Change mode, first save the changes before closing the form
if mode = "ENTER" .or. mode = "CHANGE" then
parentform.commit()
'Check to see if the record was successfully saved
if parentform.mode_get()<>"VIEW" then
ui_msg_box("Unable to save your changes","Please correct and save, or discard your changes", UI_STOP_SYMBOL)
end
end if
end if
'Close the form
parentform.close(.f.)
'Opens sites and runs saved query on Equate
query.filter = "trim(Sites->Equake)=\"Y\""
query.order = ""
'Open the layout_type showing just the records that satisfy the filter
DIM Shared varP_Sites as P
DIM layout_name as c
layout_name = "Sites"
dim tempP as p
'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
'Test if pointer is valid
if is_object(tempP) then
'Test if pointer refers to a form or browse
if tempP.class() = "form" .or. tempP.class() = "browse" then
'Apply the query to the form or browse as the Base query. (this means that
'the user cannot turn the query off, only add to the query)
tempP.BaseQueryRun(query.filter,query.order)
'then activate the already open window
tempP.activate()
else
'Window is not already open, so open it
varP_Sites = :Form.viewqueried(layout_name,query.filter, query.order )
end if
else
varP_Sites_Plus = :Form.viewqueried(layout_name,query.filter, query.order )
end if
xbasic_wait_for_idle()
tbl.close()
end if
Now, if someone can figure out how to "nest" the queries - I'd be elated...
Thank you,
Wanda
Comment