![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
On Mar 17, 12:36*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 10:24:31, imb wrote: On Mar 17, 10:43 am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 06:24:37, "Malcolm" wrote: "Salad" <sa... (AT) oilandvinegar (DOT) com> wrote in message news:ZaOdnTq3K-dTBRzQnZ2dnUVZ_gqdnZ2d (AT) earthlink (DOT) com... Phil wrote: I know this should be simple but... Having updated a record on a continuous form using VBA, I want the fo rm to scroll so that the updated record is at the top or the form. Any i dea s please Thanks Phil Nearest thing I can think of is to sort on a field (timestamp) and req uery after update. I have used this to get the result that you are after: Dim MyID As Long 'Assumes an ID field of LONG data type Dim MyRs As Object MyID = Me.FieldContainingID 'Your update code here............. Set MyRs = Me.Recordset.Clone MyRs.FindFirst "[FieldContainingID] = " & MyID Me.Bookmark = MyRs.Bookmark MyRs.Close I also added a line using SetFocus to highlight the modified field. HTH Malcolm Thanks for replying. 'Fraid it doesn't work. There is no problem getting back to the origin al record, the problem is that I want that record to be the first one vis ibl e at the top of the continuous form. I know there are complex routines with sc roll bars (My hero - Stephen Lebans) but I wonderd if there was something m ore simple in Access 2010 Phil- Hide quoted text - - Show quoted text - Hi Phil, If you got back to the original record, you could try MyForm.SelTop = MyForm.CurrentRecord to place it on the first line of your MyForm. Imb. Thanks Imb Sounds as if it should work, but Me.SelTop appears to be the same as Me.CurrentRecord, so no movement. Me.SelTop = 1 doesn't work either Phil- Hide quoted text - - Show quoted text - Hi Phil, I was a little bit to speedy with my answer. When adding a new record, I do not want it to see on the top of my form. I want to have the record on the fourth line, in order to see it in the context of the other records. When the newly added record IS already visible in the form, I have no control over its position, but when it IS NOT visible, you can bring it to the first line of the form with RecordsetClone.Findfirst. Only after that I use .SelTop to bring the newly added record to the fourth line. Imb. |
#12
| |||
| |||
|
|
On 17/03/2011 14:29:11, imb wrote: On Mar 17, 12:36 pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 10:24:31, imb wrote: On Mar 17, 10:43 am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 06:24:37, "Malcolm" wrote: "Salad" <sa... (AT) oilandvinegar (DOT) com> wrote in message news:ZaOdnTq3K-dTBRzQnZ2dnUVZ_gqdnZ2d (AT) earthlink (DOT) com... Phil wrote: I know this should be simple but... Having updated a record on a continuous form using VBA, I want the fo rm to scroll so that the updated record is at the top or the form. Any i dea s please Thanks Phil Nearest thing I can think of is to sort on a field (timestamp) and req uery after update. I have used this to get the result that you are after: Dim MyID As Long 'Assumes an ID field of LONG data type Dim MyRs As Object MyID = Me.FieldContainingID 'Your update code here............. Set MyRs = Me.Recordset.Clone MyRs.FindFirst "[FieldContainingID] = " & MyID Me.Bookmark = MyRs.Bookmark MyRs.Close I also added a line using SetFocus to highlight the modified field. HTH Malcolm Thanks for replying. 'Fraid it doesn't work. There is no problem getting back to the origin al record, the problem is that I want that record to be the first one vis ibl e at the top of the continuous form. I know there are complex routines with sc roll bars (My hero - Stephen Lebans) but I wonderd if there was something m ore simple in Access 2010 Phil- Hide quoted text - - Show quoted text - Hi Phil, If you got back to the original record, you could try MyForm.SelTop = MyForm.CurrentRecord to place it on the first line of your MyForm. Imb. Thanks Imb Sounds as if it should work, but Me.SelTop appears to be the same as Me.CurrentRecord, so no movement. Me.SelTop = 1 doesn't work either Phil- Hide quoted text - - Show quoted text - Hi Phil, I was a little bit to speedy with my answer. When adding a new record, I do not want it to see on the top of my form. I want to have the record on the fourth line, in order to see it in the context of the other records. When the newly added record IS already visible in the form, I have no control over its position, but when it IS NOT visible, you can bring it to the first line of the form with RecordsetClone.Findfirst. Only after that I use .SelTop to bring the newly added record to the fourth line. Imb. OK. I will try to resolve the confusion. I have about 100 spaces where people keep their boats Space No Boat Name 1 Daisy 2 Mable 3 QE2 4 Ark Royal . ............... Now what has happened is due to re-organisation, most of the boats have been assigned new spaces. I have written a routine where I click on a record selector (say space2), then click on a "Swap" button next to Ark Royal in Space 4, the two boats are swapped over so that Space2 now contains Ark Royal and Space 4 now contains Mable. Logically the way to get all the boats into their correct spaces is to start at Space No 1, find the boat that goes into it and do the swap. Then continue with Space no 2 and swap the correct boat into that space ad nauseam. Using this approach, the boat you are trying to find will always be lower down on the screen than the space you are trying to put it into. The screen shows about 30 spaces so assuming I have just got the correct boat into space no 45, if space 45 is now at the top of the screen, and I am trying to correct Space No 46, it will reduce the amount of scrolling I have to do to find the correct boat for space 46 because I would be able to see all those boats in spaces 45 to 75. Once I had corrected up to space 70, I would be able to see all the boats still to be assigned to their correct spaces. The form needs to be strictly in Space No order and even with a time stamp - and it seems pointless to add that field as it would only be needed temporarily. And even so, I don't see how that would get that record to the top of the visible form. Anyway I know the Space No of the record I want at the top of the screen. So to re-iterate, we are talking getting the required record to the top of portion of the subform that can be seen. So working on Space 46, Spaces 1 to 44 would be hidden above the top of the form, Spaces 45 to 74 would be visible, Spaces 75 to 99 would be hidden below the bottom of the visible form. Phil |
#13
| |||
| |||
|
|
On 17/03/2011 14:29:11, imb wrote: On Mar 17, 12:36 pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 10:24:31, imb wrote: On Mar 17, 10:43 am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote: On 17/03/2011 06:24:37, "Malcolm" wrote: "Salad" <sa... (AT) oilandvinegar (DOT) com> wrote in message news:ZaOdnTq3K-dTBRzQnZ2dnUVZ_gqdnZ2d (AT) earthlink (DOT) com... Phil wrote: I know this should be simple but... Having updated a record on a continuous form using VBA, I want the fo rm to scroll so that the updated record is at the top or the form. Any i dea s please Thanks Phil Nearest thing I can think of is to sort on a field (timestamp) and req uery after update. I have used this to get the result that you are after: Dim MyID As Long 'Assumes an ID field of LONG data type Dim MyRs As Object MyID = Me.FieldContainingID 'Your update code here............. Set MyRs = Me.Recordset.Clone MyRs.FindFirst "[FieldContainingID] = " & MyID Me.Bookmark = MyRs.Bookmark MyRs.Close I also added a line using SetFocus to highlight the modified field. HTH Malcolm Thanks for replying. 'Fraid it doesn't work. There is no problem getting back to the origin al record, the problem is that I want that record to be the first one vis ibl e at the top of the continuous form. I know there are complex routines with sc roll bars (My hero - Stephen Lebans) but I wonderd if there was something m ore simple in Access 2010 Phil- Hide quoted text - - Show quoted text - Hi Phil, If you got back to the original record, you could try MyForm.SelTop = MyForm.CurrentRecord to place it on the first line of your MyForm. Imb. Thanks Imb Sounds as if it should work, but Me.SelTop appears to be the same as Me.CurrentRecord, so no movement. Me.SelTop = 1 doesn't work either Phil- Hide quoted text - - Show quoted text - Hi Phil, I was a little bit to speedy with my answer. When adding a new record, I do not want it to see on the top of my form. I want to have the record on the fourth line, in order to see it in the context of the other records. When the newly added record IS already visible in the form, I have no control over its position, but when it IS NOT visible, you can bring it to the first line of the form with RecordsetClone.Findfirst. Only after that I use .SelTop to bring the newly added record to the fourth line. Imb. OK. *I will try to resolve the confusion. I have about 100 spaces where people keep their boats Space No * * * * * *Boat Name 1 * * * * * * * * * * * * *Daisy 2 * * * * * * * * * * * * *Mable 3 * * * * * * * * * * * * *QE2 4 * * * * * * * * * * * * *Ark Royal . * * * * * * * * * * * * *............... Now what has happened is due to re-organisation, most of the boats have been assigned new spaces. I have written a routine where I click on a record selector (say space2), then click on a "Swap" button next to Ark Royal in Space 4, the two boats are swapped over so that Space2 now contains Ark Royal and Space 4 now contains Mable. Logically the way to get all the boats into their correct spaces is to start at Space No 1, find the boat that goes into it and do the swap. Then continue with Space no 2 and swap the correct boat into that space ad nauseam. Using this approach, the boat you are trying to find will always be lower down on the screen than the space you are trying to put it into. The screen shows about 30 spaces so assuming I have just gotthe correct boat into space no 45, if space 45 is now at the top of the screen, and I am trying to correct Space No 46, it will reduce the amount of scrolling I have to do to find the correct boat for space 46 because I would be able to see all those boats in spaces 45 to 75. Once I had corrected up to space 70, I would be able to see all the boats still to be assigned to their correct spaces. The form needs to be strictly in Space No order and even with a time stamp - and it seems pointless to add that field as it would only be needed temporarily. And even so, I don t see how that would get that record to the top of the visible form. Anyway I know the Space No of the record I want at the top of the screen. So to re-iterate, we are talking getting the required record to the top of portion of the subform that can be seen. So working on Space 46, Spaces 1 to 44 would be hidden above the top of the form, Spaces 45 to 74 would be visible, Spaces 75 to 99 would be hidden below the bottom of the visible form. Phil- Hide quoted text - - Show quoted text - |
#14
| |||
| |||
|
|
Hi Phil, Nice little problem. After some puzzling, I think it is easier to revert your solution. So, starting on position 1, NOT to find the boat that has to go to pos. 1, but swap the boat now in pos.1 with its final position (from an InputBox). Continue the swapping of pos. 1, until the right boat is in pos. 1. Then go to pos. 2. If this boat is in the right position, then go to pos.3, else continu swapping until you got the right boat there. Each swap places a boat in the right position, sometimes even two boats. Quick and dirty, you could edit the Space_nr, if you are not interested in the history. Imb. Solved |
![]() |
| Thread Tools | |
| Display Modes | |
| |