Hi
 
WinXpPro Sp2
Access2002/2007
 
Does anyone know how to achieve this please? I've spent 3 x 12/14 hour days trying to get it to work. I really don't think what I'm trying to achieve is so spectacular?
 
Simple Form with a Subform. The idea is to permit users to deselect and/or re-order the order of parameters used in things like orderbys or fields on printed reports. See attached screen shot for a flavour.
 
Because I have some checking to do, I use SQL Transactions so that the users' changes don't get commited until the appropriate time (if at all).
 
I tried with DAO as my subform recordset but I need a Sort capability so that it gets displayed correctly...so I moved to ADODB for the subform's recordset.
 
Whenever I try to edit a field and .Update it I get errors... usually this one.
 
I make these declarations in the main form module.
	
	
	
		
In the Form-Open I build the transaction resources
	
	
	
		
I then manually add some records into the rs - just 1 shown here 
	
	
	
		
 
'Set the sort order on the RS and point subForm at it
	
	
	
		
So far so good!
 
I have move-up & move-down buttons which do the following:-
 
Move-Up button
a) Grabs the Unique_No (PKey) and existing List_Order_No of current record.
b) Substracts 1 from the current row's List_Order_No
c) Does a FIND to see which record 'owns' that list order no. moves to that record and does an update of List_Order_No to demote it.
d) Does a FIND to go to previously selected record and does an update of the List_Order_No to promote it.
 
Up-Button-Click
	
	
	
		
And it's at the .Update that it fails.... If I leave thr .Update out it fails when trying to move to another record.
 
I've tried different cursors, connections, AddNews before and after assignment of the subform Rs... I saw threads talking about having no defaults set up for nunber fields.... well, you name it, I've tried it...
 
Thanks
 WinXpPro Sp2
Access2002/2007
Does anyone know how to achieve this please? I've spent 3 x 12/14 hour days trying to get it to work. I really don't think what I'm trying to achieve is so spectacular?
Simple Form with a Subform. The idea is to permit users to deselect and/or re-order the order of parameters used in things like orderbys or fields on printed reports. See attached screen shot for a flavour.
Because I have some checking to do, I use SQL Transactions so that the users' changes don't get commited until the appropriate time (if at all).
I tried with DAO as my subform recordset but I need a Sort capability so that it gets displayed correctly...so I moved to ADODB for the subform's recordset.
Whenever I try to edit a field and .Update it I get errors... usually this one.
Error No: -2147217864 - Error Decription: Row cannot be located for updating. Some values may have been changed since it was last read.
I make these declarations in the main form module.
		Code:
	
	
	Public Edit_rstADO As New ADODB.Recordset
Public Edit_Cnn As ADODB.Connection
Public Edit_Transaction_Begun As Boolean
	
		Code:
	
	
	 'Set up Transaction resources
Set Edit_Cnn = CurrentProject.AccessConnection
 
'Set SQL String to Load an empty recordset 
SQLLine = "SELECT TBL1.* FROM Form_Sort_And_Filter_Fields AS TBL1 WHERE Unique_No = -999" 
 
'Open the RS
Edit_rstADO.Open SQLLine, Edit_Cnn, adUseClient, adLockOptimistic
Edit_Cnn.BeginTrans
Edit_Transaction_Begun = True
	
		Code:
	
	
	'Add some records into the RS
Edit_rstADO.AddNew
Edit_rstADO![Table_Friendly_Name] = Sort_Args(1)
Edit_rstADO![Field_Friendly_Name] = Sort_Args(2)
Edit_rstADO![OrderBy_Direction] = Sort_Args(3)
Edit_rstADO![Field_Selected] = True
Edit_rstADO![List_Order] = List_Order_No
Edit_rstADO.Update
	'Set the sort order on the RS and point subForm at it
		Code:
	
	
	Edit_rstADO.Sort = "List_Order"
Set My_Fields_SubForm.Form.Recordset = Edit_rstADO
	I have move-up & move-down buttons which do the following:-
Move-Up button
a) Grabs the Unique_No (PKey) and existing List_Order_No of current record.
b) Substracts 1 from the current row's List_Order_No
c) Does a FIND to see which record 'owns' that list order no. moves to that record and does an update of List_Order_No to demote it.
d) Does a FIND to go to previously selected record and does an update of the List_Order_No to promote it.
Up-Button-Click
		Code:
	
	
	'Dim all the variables here.........including another Rs:-
Dim....
Dim....
Dim rst As New ADODB.Recordset
 
Set Cntrlbx = My_Fields_SubForm
 
Extg_List_Order = Cntrlbx.Form!List_Order
Trgt_List_Order = (Extg_List_Order) -1
 
Set rst = Cntrlbx.Form.RecordsetClone
rst.Find "List_Order=" & Trgt_List_Order
If rst.EOF Then
       MsgBox "Ouch"
End If
 
'Move the Form Rs to the record just found
Cntrlbx.Form.Recordset.Bookmark = rst.Bookmark
Cntrlbx.Form.Recordset.Fields("List_Order") = Extg_List_Order
Cntrlbx.Form.Recordset.Update
 
etc etc....
	I've tried different cursors, connections, AddNews before and after assignment of the subform Rs... I saw threads talking about having no defaults set up for nunber fields.... well, you name it, I've tried it...
Thanks
Attachments
			
				Last edited: