dbTalk Databases Forums  

Scroll a continuous form

comp.databases.ms-access comp.databases.ms-access


Discuss Scroll a continuous form in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Scroll a continuous form - 03-16-2011 , 05:15 PM






I know this should be simple but...
Having updated a record on a continuous form using VBA, I want the form to
scroll so that the updated record is at the top or the form. Any ideas please

Thanks
Phil

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Scroll a continuous form - 03-16-2011 , 11:14 PM






Phil wrote:

Quote:
I know this should be simple but...
Having updated a record on a continuous form using VBA, I want the form to
scroll so that the updated record is at the top or the form. Any ideas please

Thanks
Phil

Nearest thing I can think of is to sort on a field (timestamp) and
requery after update.

Reply With Quote
  #3  
Old   
Malcolm
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 12:24 AM



"Salad" <salad (AT) oilandvinegar (DOT) com> wrote

Quote:
Phil wrote:

I know this should be simple but...
Having updated a record on a continuous form using VBA, I want the form
to
scroll so that the updated record is at the top or the form. Any ideas
please

Thanks
Phil

Nearest thing I can think of is to sort on a field (timestamp) and requery
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

Reply With Quote
  #4  
Old   
Phil
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 03:43 AM



On 17/03/2011 06:24:37, "Malcolm" wrote:
Quote:
"Salad" <salad (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 form
to
scroll so that the updated record is at the top or the form. Any ideas
please

Thanks
Phil

Nearest thing I can think of is to sort on a field (timestamp) and requery
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 original
record, the problem is that I want that record to be the first one visible at
the top of the continuous form. I know there are complex routines with scroll
bars (My hero - Stephen Lebans) but I wonderd if there was something more
simple in Access 2010 Phil

Reply With Quote
  #5  
Old   
imb
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 04:24 AM



On Mar 17, 10:43*am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
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 form
to
scroll so that the updated record is at the top or the form. Any ideas
please

Thanks
Phil

Nearest thing I can think of is to sort on a field (timestamp) and requery
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 original
record, the problem is that I want that record to be the first one visible at
the top of the continuous form. I know there are complex routines with scroll
bars (My hero - Stephen Lebans) but I wonderd if there was something more
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.

Reply With Quote
  #6  
Old   
Phil
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 05:36 AM



On 17/03/2011 10:24:31, imb wrote:
Quote:
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 idea
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 original
record, the problem is that I want that record to be the first one visibl
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 more
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

Reply With Quote
  #7  
Old   
ron paii
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 06:46 AM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 17/03/2011 06:24:37, "Malcolm" wrote:
"Salad" <salad (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 form
to
scroll so that the updated record is at the top or the form. Any ideas
please

Thanks
Phil

Nearest thing I can think of is to sort on a field (timestamp) and
requery
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 original
record, the problem is that I want that record to be the first one visible
at
the top of the continuous form. I know there are complex routines with
scroll
bars (My hero - Stephen Lebans) but I wonderd if there was something more
simple in Access 2010 Phil
You will need to go back to Salad's reply.

Assuming your form is based on a query, sort your query on a column that
will caused the changed record to sort 1st. Then do a requery on your form
after the edit.

Reply With Quote
  #8  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 07:05 AM



Try:

DoCmd.GoToRecord , , acGoTo, Me.CurrentRecord

HTH

Jon

"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
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
idea
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 original
record, the problem is that I want that record to be the first one
visibl
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
more
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

Reply With Quote
  #9  
Old   
John Spencer
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 07:16 AM



Ok, I am a bit confused as to what you want.

Do you want the updated record to be the first row in the continuous form or
just to be the record that shows at the top of the form?

For example, if the updated record is the 25th record in the recordset, do you
now want it to be the first record in the recordset or do you just want the
25th record to be the top record showing in the form (scroll down to record 25).

If the first choice is your desire then you obviously need to force the
records to sort in an order that will make the record the first record. Which
means you need a last updated field to sort by or you need to sort by the
primary key of the record. Assuming 22 was the primary key of the updated
record and you regular sort was by a field named OrderDate, you would need an
ORDER BY something like

ORDER BY PrimaryKeyField = 22, OrderDate

IF the second choice, you would need to set the focus to the record that you
have modified and then use
Me.SelTop = Me.CurrentRecord
Although that won't scroll the record to the top of the form, so it may be
that you need to use some code from Lebans' site.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

On 3/17/2011 7:36 AM, Phil wrote:

Reply With Quote
  #10  
Old   
imb
 
Posts: n/a

Default Re: Scroll a continuous form - 03-17-2011 , 08:29 AM



On Mar 17, 12:36*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
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 thefo
rm
to
scroll so that the updated record is at the top or the form. Any idea
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 original
record, the problem is that I want that record to be the first one visibl
e at
the top of the continuous form. I know there are complex routines withsc
roll
bars (My hero - Stephen Lebans) but I wonderd if there was something more
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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.