The following code in located in the AfterValidate event of a dialog component. The query filter is not working. It is populating session.new_client_id with the value of the field New_Clien_ID from the first record in the table, regardless of the query filter.
I suspect that I need to use alltrim() on the field in the table in the filter expression, but can't get the syntax right...or maybe this isn't the problem?
Thanks for any help that can be offered!
Louis
=======Code Follows==========
dim tbl as p
tbl = table.open("[PathAlias.ADB_Path]\tbl_new_client",FILE_RW_SHARED)
tbl.enter_begin()
tbl.company_name = convert_type(company_name,"Character")
tbl.Street_address_1 = convert_type(street_address_1,"Character")
tbl.Street_address_2 = convert_type(Street_address_2,"Character")
tbl.Street_city= convert_type(Street_City,"Character")
tbl.Street_state = convert_type(Street_State,"Character")
tbl.Street_zip_code = convert_type(Street_Zip_Code,"Character")
tbl.Prefix = convert_type(prefix,"Character")
tbl.First_name = convert_type(first_name,"Character")
tbl.Middle_name = convert_type(middle_name,"Character")
tbl.Last_name = convert_type(last_name,"Character")
tbl.Suffix = convert_type(suffix,"Character")
tbl.Title = convert_type(title,"Character")
tbl.Email_address = convert_type(email_address,"Character")
tbl.Telephone = convert_type(telephone,"Character")
tbl.Fax = convert_type(fax,"Character")
tbl.enter_end(.t.)
tbl.close()
'====Create session.new_client_id and populate it with the client_id just created in tbl_new_client
dim tbl as p
tbl = table.open("[PathAlias.ADB_Path]\tbl_new_client",FILE_RW_SHARED)
query.filter = "Telephone = telephone"
query.order = ""
query.flags = ""
dim i_tbl as p
i_tbl = tbl.query_create()
dim recs as n
recs = i_tbl.records_get()
if recs = 0 then
ui_msg_box("Error","No records satisfy the query '" + query.filter + "'.",UI_STOP_SYMBOL)
end
end if
tbl.fetch_first()
session.new_client_id = tbl.eval("New_Client_Id")
tbl.close()
CurrentForm.RedirectTarget = "new_debt_new_client.a5w"
========End of Code==========
I suspect that I need to use alltrim() on the field in the table in the filter expression, but can't get the syntax right...or maybe this isn't the problem?
Thanks for any help that can be offered!
Louis
=======Code Follows==========
dim tbl as p
tbl = table.open("[PathAlias.ADB_Path]\tbl_new_client",FILE_RW_SHARED)
tbl.enter_begin()
tbl.company_name = convert_type(company_name,"Character")
tbl.Street_address_1 = convert_type(street_address_1,"Character")
tbl.Street_address_2 = convert_type(Street_address_2,"Character")
tbl.Street_city= convert_type(Street_City,"Character")
tbl.Street_state = convert_type(Street_State,"Character")
tbl.Street_zip_code = convert_type(Street_Zip_Code,"Character")
tbl.Prefix = convert_type(prefix,"Character")
tbl.First_name = convert_type(first_name,"Character")
tbl.Middle_name = convert_type(middle_name,"Character")
tbl.Last_name = convert_type(last_name,"Character")
tbl.Suffix = convert_type(suffix,"Character")
tbl.Title = convert_type(title,"Character")
tbl.Email_address = convert_type(email_address,"Character")
tbl.Telephone = convert_type(telephone,"Character")
tbl.Fax = convert_type(fax,"Character")
tbl.enter_end(.t.)
tbl.close()
'====Create session.new_client_id and populate it with the client_id just created in tbl_new_client
dim tbl as p
tbl = table.open("[PathAlias.ADB_Path]\tbl_new_client",FILE_RW_SHARED)
query.filter = "Telephone = telephone"
query.order = ""
query.flags = ""
dim i_tbl as p
i_tbl = tbl.query_create()
dim recs as n
recs = i_tbl.records_get()
if recs = 0 then
ui_msg_box("Error","No records satisfy the query '" + query.filter + "'.",UI_STOP_SYMBOL)
end
end if
tbl.fetch_first()
session.new_client_id = tbl.eval("New_Client_Id")
tbl.close()
CurrentForm.RedirectTarget = "new_debt_new_client.a5w"
========End of Code==========
Comment