473,545 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I determine the position of the scroll bar in datasheet view?

8 New Member
I have a form shown in datasheet view, and I have some actions that require that form to be requeried with a delete operation, however number of rows in the datasheet view remains constant with a delete operation in this specific case.

I am trying to return the user back to the same row that he just selected the action on, and also at the same position on the screen - i.e. the same row and the same position of the scrollbar.

An example:

datasheet has 100 records (rows)

User is currently viewing records 45-60 (scrollbar is approximately half way down)

The user selects record 56 for the action.

The action finishes, the records are requeried to reflect the change (I have so far been unable to replicate this without the requery)

I am able to return the user to the record 56, but it is located at the bottom of the window now, not about halfway up as it was when it was selected. I also can figure out how to get it to be at the top of the list, but I want it to return the same position.

Anyone have any idea how to do this?

Thanks in advance!
May 12 '07 #1
16 12581
ulam
8 New Member
Sorry forgot to mention - Access 2003
May 12 '07 #2
JConsulting
603 Recognized Expert Contributor
Sorry forgot to mention - Access 2003
Look into the Bookmark property.

if you set the bookmark at the current record number, do your delete action then reset the bookmark to that same number, you have effectively remained in place.

experiment also with refresh vs requery.

J
May 12 '07 #3
ulam
8 New Member
Look into the Bookmark property.

if you set the bookmark at the current record number, do your delete action then reset the bookmark to that same number, you have effectively remained in place.

experiment also with refresh vs requery.

J
I am currently using the bookmark to return the correct number. As I mentioned the problem is not in returning the the correct record. The problem is that when I return to that record it is not in the same row as it was before the operation.

I did try to use refresh after your suggestion with some success, but that resulted in some bizarre behavior that I can maybe get around but requery most certainly works better if I can figure out the scroll bar position.

Perhaps I wasn't clear, so let me try again,
I have a query that returns 100 records.
In the datasheet view (it's a subform so viewing area is limited) there is room for approx. 25 records to be seen at a time.
Therefore to see the record in row 57 the user must scroll down to it by some mechanism. However that is done the scroll bar does advance to reflect which portion of the total 100 records the currently seen 25 records are from.

If we assume the user uses the mouse to scroll down to record 57, its safe to assume it unlikely the user will scroll until record 57 is exactly the record in the 25th row of the viewable area. For the sake of example, lets say the records in view after the scroll down are records 51 through 75. So in row 1 is record 51 and in row 25 is record 75. The record to be changed is #57 which is in row 7.

After the edits are made - (it's only in one specific case, not just any edit, but I must handle this special case as well), a requery is called.

If I save a bookmark and return to the same record, or by saving the selTop and resetting it (same effect for both). After the requery and reset of position I am left with:
The user is viewing records 33 through 57, with the editied record now in row 25.
What I am wishing to accomplish is after the requery reestablish the state of the scrollbar not just the recordnumber. So after the requery the user is still viewing records 51-75 and the edited record is still located in row7.

As far as I am aware the bookmark property isn't going to solve this one, am I missing something?

Is there really no way to find out which records are in view, or some indication of the position of the scrollbar?
May 13 '07 #4
ADezii
8,834 Recognized Expert Expert
I have a form shown in datasheet view, and I have some actions that require that form to be requeried with a delete operation, however number of rows in the datasheet view remains constant with a delete operation in this specific case.

I am trying to return the user back to the same row that he just selected the action on, and also at the same position on the screen - i.e. the same row and the same position of the scrollbar.

An example:

datasheet has 100 records (rows)

User is currently viewing records 45-60 (scrollbar is approximately half way down)

The user selects record 56 for the action.

The action finishes, the records are requeried to reflect the change (I have so far been unable to replicate this without the requery)

I am able to return the user to the record 56, but it is located at the bottom of the window now, not about halfway up as it was when it was selected. I also can figure out how to get it to be at the top of the list, but I want it to return the same position.

Anyone have any idea how to do this?

Thanks in advance!
  1. In the AfterUpdate() Event of the Form and prior to the Requery, calculate the PercentPosition Property of the underlying Recordset.
  2. Perform the Requery.
  3. Set the PercentPosition Property to the value (SINGLE) between 0.0 and 100.00 that was previously calculated.
  4. The Scroll Bar should dynamically adjust and be positioned exactly where it was.
  5. Is this what you were looking for?
May 13 '07 #5
JConsulting
603 Recognized Expert Contributor
  1. In the AfterUpdate() Event of the Form and prior to the Requery, calculate the PercentPosition Property of the underlying Recordset.
  2. Perform the Requery.
  3. Set the PercentPosition Property to the value (SINGLE) between 0.0 and 100.00 that was previously calculated.
  4. The Scroll Bar should dynamically adjust and be positioned exactly where it was.
  5. Is this what you were looking for?
Sounds like you wish to be able to delete a record, perform the requery, then reposition things as if the record had simply disappeared...t he same record as before is at the top of your viewing area...and you are poitioned at the "next" record (obviously because the one you were on is gone)..so it appears to be a seamless operation. Returning to the bookmark works but returns that record as record 1 in your viewing area...but really record 1 should be 7 records up?? so you need a way to figure out not only what record you're on, but also what relative position you were in to calculate what is the first record to show at the top of your viewing area. If that's the case, ADz's solution may work...I'll play around with this as well...just in case it doesn't.
J
May 13 '07 #6
dima69
181 Recognized Expert New Member
I'm sorry but I don't see how ADezii's solution can work.
I can suggest two things here, which can give only partial solution.
1. If all you need to do is delete one record, use
Expand|Select|Wrap|Line Numbers
  1. docmd.RunCommand acCmdDeleteRecord
This way you don't have to requery, so everything stays where it was.
2. If your list is a subform on the main form, requery the subform control instead of requerying the form, i.e. from the main form:
Expand|Select|Wrap|Line Numbers
  1. Me![SubFRM].Requery
where SubFRM is the name of subform control, or from the subform:
Expand|Select|Wrap|Line Numbers
  1. Me.Parent![SubFRM].Requery
However, this works only if no ordering is applyed on the form, otherwise it works like a form requery, jumping to the first record.
May 13 '07 #7
ulam
8 New Member
Thanks for the suggestions! I will give ADezii's method a try first.

For anyone that is playing around with this - some more info will help you recreate the scenario.

The form (it will be a subform - but for now just getting this functionality in a form is sufficient) is based on a left join query. There are two fields, the first is a checkbox (yes/no or whatever) that is calculated. The second field is an ID field - number.

i.e.
select tableb.field1, tablea.field1 from tablea left join tableb on (tablea.id = tableb.id)

The ID's correspond to all of the records in the left side of the left join.
The calculated checkbox is merely checking for nulls on field on the right side of the join.

The interface allows the user to change the checkbox from checked to not checked (which requires a delete from tableb) or to place a check in the checkbox (which requires an insert into tableb)

Adding a new record by typing in a new ID in a new record of the recordset inserts a new record into tablea, but does nothing to tableb.

I am currently utilizing the On Mouse Down event to detect a 'click' in the checkbox to handle the delete/insert in tableb.

I have the insert (add a checkbox) working, and it does not require a refresh or requery.

It is the delete that causes the problems. When I used the refresh, the checkbox does disappear. But if I click that same box a second time to then do an insert (even if clicking other boxes between the 1st and 2nd time) The insert to tablea appears, but the checkbox does not get a check. So it's entirely possible to click it a third time and a duplicate insert is attempted - which I could catch and just skip, but the missing check in the checkbox is the actual problem.

So the list of ID's never changes, consequently even after a delete the row still exists - due to the left join.

I can make this easier by changing the tables a little - but I preferred this arrangement if I can work out this last little quirk in repositioning the scrollbar after a requery.
May 13 '07 #8
ulam
8 New Member
  1. In the AfterUpdate() Event of the Form and prior to the Requery, calculate the PercentPosition Property of the underlying Recordset.
  2. Perform the Requery.
  3. Set the PercentPosition Property to the value (SINGLE) between 0.0 and 100.00 that was previously calculated.
  4. The Scroll Bar should dynamically adjust and be positioned exactly where it was.
  5. Is this what you were looking for?
I tried this and landed one record worse than using bookmarks. I'm not sure what you mean by calculating the PercentPosition Property so perhaps I didn't do this correctly. The PercentPosition has a value that is approximately correct prior to the requery, so I just saved that value and then reset it after the the requery. If there was more to it, could you kindly explain what else you intended, please.


I have also ran across this link:
http://www.lebans.com/setgetsb.htm
but am so far unsuccessful getting this to work in WindowsXP with Access 2003.
May 14 '07 #9
ADezii
8,834 Recognized Expert Expert
I tried this and landed one record worse than using bookmarks. I'm not sure what you mean by calculating the PercentPosition Property so perhaps I didn't do this correctly. The PercentPosition has a value that is approximately correct prior to the requery, so I just saved that value and then reset it after the the requery. If there was more to it, could you kindly explain what else you intended, please.


I have also ran across this link:
http://www.lebans.com/setgetsb.htm
but am so far unsuccessful getting this to work in WindowsXP with Access 2003.
The PercentPosition property or returns a value indicating the approximate location of the current record in the Recordset object based on a percentage of the records in the Recordset. It return value is a Single that is a number between 0.0 and 100.00. The pseudo code for the calculation of PercentPosition would be:

Expand|Select|Wrap|Line Numbers
  1. ((CurrentRecordNumber) / (TotalNumber of Records in Recordset)) * 100
May 14 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
18042
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and I've Googled so much my brain hurts. http://www.ghpkendal.co.uk/TestPages/Test.htm Move your cursor over the yellow area and you should see the...
4
9346
by: John | last post by:
Hi I have a small pop non-dialog form that I need to appear towards the right side of the screen. Is there a way to achieve this? Regards
3
6069
by: rmunson8 | last post by:
I have added Panel control to a web page which contains a GridView. The Panel's ScrollBars property is set to auto. When I select the Select CommanField button for a row (which obviously causes a postback), the scroll position resets to the top. I was unable to figure out how to not force a postback or how to reset the scroll position of...
1
4225
by: Lancelot | last post by:
Hi, I want to keep the scroll position after reload. I tried this: function f_scrollTop() { // returns scroll position } function scrollPosition() { document.buy_from_shop_form.scrollpos.value = f_scrollTop();
3
3980
by: ApexData | last post by:
I have created a SearchForm which is basically a PopUp Continuous Form that displays 15 Fields. Each field is displayed as a column and when the user clicks on any record or row, the form closes and that complete record is displayed in the MainForm. At the bottom of the SearchForm is the Horizontal Scroll Bar. This lets the user view all...
3
2209
by: OldBirdman | last post by:
I have several PopUp forms in my database. Before today, if I switched to Design View, the form was in the same position as in Form View. Currently if I switch to Design View, the form is positioned below any open forms, sometimes as many as 5 screens below the active forms (lots of blank space here). Access adds a vertical scroll bar to...
0
1500
by: Sobin | last post by:
I am new to ASP .NET. In my webpage there is a panel with vertical scroll bar enabled.Inside the panel there is a treeview control.I'm populating its nodes at run time through database connection.The nodes are large in number, sothat I've to scroll down to view the last nodes. The problem is that when I scroll down to see the bottom most...
1
2393
by: Solaron | last post by:
Hi Guys, i would have thought this is a simple problem - but i dont have a clue how to do it. Basically, i have two subforms in one view - both datasheet view. I want to have it that when you scroll down on one subform, it will scroll down on the other too. Because of this stupiid 'records not updatable' problem, i cant put it all into...
4
3376
by: Paul Engel | last post by:
I have an application on which I have a tab control with two tabs. When a user double-clicks on an item in tab1 of my tabs collection, tab2 becomes the visible tab. (tabImageTabs.SelectedIndex = 1) When they double-click on the content in tab2, they are taken back to tab1. (tabImageTabs.SelectedIndex = 0) When tab1 is restored, I have lost...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.