Ok, here is the deal. I have a browse, and I do a sort that sorts the browse. I added a column to the browse that has an update button, a nice little trick I didn't know about and found earlier while looking for help with this problem. Anyway, here is my problem. In A5v5, I did a search based on a specific criteria, sorted the records and then displayed the browse with all matching records. The use would then select which row they wanted to update, and then hit an update button on the form that would take them to a new form that had the single record open with all the existing data available to be changed and added to. Overly complicated yes, but it is a lot of data to change, so easier to just make a new form for it. Anyway, when I converted over to v9, everything worked except for one small thing and I can't seem to make it function properly.
On either the update button on the form, or the update button in the browse (which I prefer since it's more obvious which record is to be updated) when I press the button to run the update code, it does everything it's supposed to do, except that when it opens the new form, it is on record #1, not the sorted or queried record. I don't get any code errors, I don't get any wonkiness, it looks like it works, then reverts to a non sorted/queried table. It then opens the form on record #1.
Here is the update code for the button in the browse.
Everything that is not part of the FUNCTION itself (i.e. the button in the browse) is what I copied over from my v5 code that still works perfectly in v5. I click the record, hit update and voila. If anybody can see what I did wrong, or if it's changed any or if something should be different, or even just a good thread to go read that I may have missed, I don't mind figuring it out, just gotten stuck is all. Thanks!
Jason
FUNCTION UPDATE0_ButtonClick AS V ( event AS C, data AS C , row AS N )
'DESCRIPTION: Fired when a button is clicked on a column.
'Arguments: event - the name of the event that is fired
' data - the data in the column cell
' row - the row number in the browse
'this.SetViewport_Row() sets the current row to the row with the button that was clicked.
this.Set_Viewport_row(row)
DIM Shared varP_UpdateReport as P
DIM layout_name1 as c
DIM layout_name2 as c
DIM layout_name3 as c
dim tbl as p
dim record_number as n
layout_name1 = "Reports - Modify"
layout_name2 = "Reports - Vehicle"
layout_name3 = "Reports - NewCustomer"
tbl = table.current()
record_number = current_record_number()
query.filter = "recno() = " + record_number
query.order = ""
indx = tbl.query_create()
if tbl.vehicle = .T.
varP_UpdateReport = :Form.view(layout_name2)
else if tbl.Newcustomer = .T.
varP_UpdateReport = :Form.view(layout_name3)
else
varP_UpdateReport = :Form.view(layout_name1)
end if
END FUNCTION
On either the update button on the form, or the update button in the browse (which I prefer since it's more obvious which record is to be updated) when I press the button to run the update code, it does everything it's supposed to do, except that when it opens the new form, it is on record #1, not the sorted or queried record. I don't get any code errors, I don't get any wonkiness, it looks like it works, then reverts to a non sorted/queried table. It then opens the form on record #1.
Here is the update code for the button in the browse.
Everything that is not part of the FUNCTION itself (i.e. the button in the browse) is what I copied over from my v5 code that still works perfectly in v5. I click the record, hit update and voila. If anybody can see what I did wrong, or if it's changed any or if something should be different, or even just a good thread to go read that I may have missed, I don't mind figuring it out, just gotten stuck is all. Thanks!
Jason
FUNCTION UPDATE0_ButtonClick AS V ( event AS C, data AS C , row AS N )
'DESCRIPTION: Fired when a button is clicked on a column.
'Arguments: event - the name of the event that is fired
' data - the data in the column cell
' row - the row number in the browse
'this.SetViewport_Row() sets the current row to the row with the button that was clicked.
this.Set_Viewport_row(row)
DIM Shared varP_UpdateReport as P
DIM layout_name1 as c
DIM layout_name2 as c
DIM layout_name3 as c
dim tbl as p
dim record_number as n
layout_name1 = "Reports - Modify"
layout_name2 = "Reports - Vehicle"
layout_name3 = "Reports - NewCustomer"
tbl = table.current()
record_number = current_record_number()
query.filter = "recno() = " + record_number
query.order = ""
indx = tbl.query_create()
if tbl.vehicle = .T.
varP_UpdateReport = :Form.view(layout_name2)
else if tbl.Newcustomer = .T.
varP_UpdateReport = :Form.view(layout_name3)
else
varP_UpdateReport = :Form.view(layout_name1)
end if
END FUNCTION
Comment