473,473 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Scroll control of Access Form and Subform

7 New Member
I am seeking code that will horizontally scroll a subform off the page as a user scrolls the parent form off the page (column for column). Form and subform are both in datasheet view. I am working in Access-2016 under Win10.

Stephen Lebans' open source solution is too complex for me, and apparently obsolete for anything beyond Access-2003. His solution is part API programming, and the scuttlebutt seems to be that scroll control in datasheet view is under API control, not Access/VBA control.

Oh, and I might add that I am a VBA neophyte.
Jan 23 '19 #1

✓ answered by twinnyfo

Thus, you have uncovered one of the many challenges/weaknesses (Microsoft would call it a "feature") of using Sendkeys(). You would have to access the system's activity to see of a user were doing things without doing other things first.

Again, based upon what you are doing, you may be stuck with using SendKeys(). I've been trying to think of some alternate methods of displaying what you want to display by using the standard tools Access has made available to us....

9 4194
twinnyfo
3,653 Recognized Expert Moderator Specialist
gburch,

I don't know of any pure VBA solution to this.

However, an alternative method may be to create a set of your own navigation buttons which, when one clicks to "scroll" right, the left most column of the main form and subform are hidden and the next available column to the right is unhidden.

This is just thinking out loud--I've never tried anything like this. However, it seems that you have a very "wide" dataset on these two forms that you want to keep in sync?

Either way, there could be considerable challenges with these approaches, and there would be no "easy" way for you to design this.
Jan 23 '19 #2
gburch
7 New Member
Dear Twinnyfo,

I don't much care if the solution is VBA or C#, as long as it works.

Anmd, yes, it is a wide dataset - a field for each week with a summary field for each month - it spans out to the end of Calendar Year 2019. I will be adding blocks of a calendar-quarter from time to time.

Not sure what you have in mind with creating a set of "navigation buttons". The term Navigation Button is an Access Property, but it applies to Record navigation (i.e., Vertical), and my problem is Horizontal.

However, I will do some internet searching on the topic of "creating navigation buttons" and see what I come up with. Perhaps you are thinking outside the box, while I am still a prisoner in it.

Glen

PS I like your Goofy logo - "ahyilk".
Jan 24 '19 #3
NeoPa
32,556 Recognized Expert Moderator MVP
GBurch:
I don't much care if the solution is VBA or C#, as long as it works.
I think you misunderstand. Introducing another programming language at all is an extremely complex path. Twinny was referring to using VBA (The only language available natively to Access.) in conjunction with other design changes on your form.

You're right to be confused by the term Navigation Button when used in this context. I suspect Twinny was simply referring to a Command Button added to your form that would be used to aid lateral navigation of your data. It isn't a simple solution by any means, certainly not for a novice as you say you are, but if you come here with complicated and unusual requests you can't be too surprised if the answers aren't found within neat boxes.

Most of our experts are happy to hold your hand through your learning but you should know this is far from trivial. Nevertheless, it sounds like Twinny may have some ideas for you. It may help if you could give an indication of how prepared you are to stick with this if it gets a little complicated for you.
Jan 24 '19 #4
gburch
7 New Member
Dear NeoPa,

Yes, I am committed to pressing on with a solution.

I have tried for weeks to get some version of Stephen Lebans' GetSetScrollInfo working. Also someone posted an updated version of this (for later ver. of Access) and it includes a small demo, but I have been to duplicate it - in fact I just took another look at it, and it locked up Access-2016.

Any and all tips are appreciated.

Glen
Jan 24 '19 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
Yes - my suggestion was designing command buttons to do your scrolling for you on the form.
Jan 25 '19 #6
gburch
7 New Member
I'm posting this update for the sake of the community - others may be interested in these solutions.

I have two buttons on my Switchboard for updating the Labor Plan. The Top-Down view uses a totalizing query as Record Source for the main form. The subform contains the individual projects that each person has time planned for (as a % of his time for each weekly period). When the user selects the "Top-Down" button, a datasheet opens with the total commitment (usually 100%) for an alphabetical list of all employees. When an employee-of-interest is to be updated, the user selects the "+" at the left margin and a subdatasheet for that individual opens, exposing the projects he/she has historically supported. As each weekly entry for a given project is updated, the focus jumps to the control to the right.

What follows is the Event Procedure that keeps the main form and subform controls for each week aligned one-over-the-other:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl3_10_19_AfterUpdate()
  2. Dim strPK1, strPK2, strBookmark As String
  3. Me.Refresh
  4. strPK2 = Me!Names
  5. strBookmark = Me.Bookmark
  6. Forms!frmTPL.SetFocus
  7. Forms!frmTPL.Form.SetFocus
  8. Parent.Requery
  9. DoCmd.FindRecord (strPK2)
  10. Me.Parent.Form![SumOf3/17/19].SetFocus
  11. Me.Parent![Labor Plan].SetFocus
  12. Me.Parent![Labor Plan].Form.Bookmark = strBookmark
  13. Me.Parent![Labor Plan].Form![3/17/19].SetFocus
  14. End Sub
Of course, I had to tailor the date references for each weekly control. Note that strPK1 is an abandoned variable.

When it came to working the Bottom-Up view, I thought it would be a simple matter of reversing the references to main forms and subforms, but that did not work. Also, I had noticed an undesirable bit of user behavior - not clicking the "+" to open the subform. The subform for this now contained the individual person's total commitments for the week. The main form contained the person's individual project planning - in some cases 3 or 4 projects might be listed. I thought it was important that a user making updates see what effect the updates were having on the totals - a person might end up overbooked or underbooked if this was ignored. The only way I could open a single instance of a subdatasheet (all other methods opened them all, making far too busy a screen) was with SendKeys and a keyboard shortcut. Then I began to notice a curious thing - any procedure executing a SendKey will no longer execute a SetFocus method. So I had to keep using the SendKey/shortcuts methodology to get the focus where I wanted it. It was a bit more code than I would have liked, but it finally worked. Here's what worked:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl2_3_19_AfterUpdate()    'This procedure
  2.               synchronizes scrolling between form and 
  3.               subform – but does NOT work if user tabs 
  4.               through controls.
  5. With Forms!frmLPT
  6.         Dim intTabIndex1, intTabIndex2, intTabIndex3 As Integer
  7.         intTabIndex1 = Me![2/3/19].TabIndex
  8.         intTabIndex2 = intTabIndex1 + 1
  9.         intTabIndex3 = intTabIndex2 - 44    
  10.         Me![sfrmLPT_Subtotals].SetFocus
  11.     If Forms!frmLPT![sfrmLPT_Subtotals].Form.SubdatasheetExpanded = False Then        
  12.     ‘MsgBox (SubdatasheetExpanded)        ‘used as a test to see if this path was being followed
  13.         'Me.Refresh                                   'Refreshes even without this statement
  14.         '[sfrmLPT_Subtotals].Requery                 'Requeries even without this statement
  15.         SendKeys "+^{DOWN}", True                   'Opens single instance of Subdatasheet
  16.         Do  ‘this Loop TABs over to next chronological
  17.               control on subform
  18.             SendKeys "{Tab}", True
  19.             intTabIndex3 = intTabIndex3 - 1
  20.             If intTabIndex3 = 0 Then
  21.                 Exit Do
  22.             End If
  23.         Loop
  24.         SendKeys "^{TAB}", True 'Exits subdatasheet & 
  25. moves to next 
  26.                 datasheet record
  27.         SendKeys "{UP}", True     'Shifts focus to previous record, bypassing subdatasheet
  28.         'Forms!frmLPT![2/10/19].SetFocus         'this will NOT reset focus
  29.         intTabIndex3 = intTabIndex2 - 43
  30.         Do  ‘this Loop TABs over to next chronological
  31.  control on main form
  32.             SendKeys "{Tab}", True
  33.             intTabIndex3 = intTabIndex3 - 1
  34.             If intTabIndex3 = 0 Then
  35.                 Exit Do
  36.             End If
  37.         Loop
  38.     Else ‘if subdatasheet already open, this path is followed
  39.     ‘MsgBox (SubdatasheetExpanded)        ‘used as a test to see if this path was being followed
  40.  
  41.         Me.Refresh
  42.         [sfrmLPT_Subtotals].Requery
  43.         Forms!frmLPT!sfrmLPT_Subtotals.SetFocus
  44.         Forms!frmLPT!sfrmLPT_Subtotals.Form![SumOf2/10/19].SetFocus
  45.         Forms!frmLPT.SetFocus
  46.         Forms!frmLPT![2/10/19].SetFocus
  47.     End If
  48. End With
  49. End Sub
Someone who understands Event handling can perhaps explain why the use of SendKeys in a procedure turns OFF the SetFocus method. I could not find this documented anywhere, but it seems to be inductively proven by this experience.

Also, synchronized scrolling will not work if a user tabs through a series of controls to get to a starting control of interest. When I tried using the procedure above with the LostFocus Event on a single control, the program went into an endless loop and overwrote code in other control events - in a word, a disaster!

Is there any way to make an Event Procedure conditional?
Mar 1 '19 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
I'm glad you found a solution, although I always try to shy away from using SendKeys() when possible, because a user clicking anywhere else while the code is executing will cause problems. However, I understand that there are times when this is a necessity. I use a variation in my own projects from time to time.

I would also ask you to reconsider your naming conventions for Fields/Controls. The name "SumOf3/17/19"--for whatever reason--is a naming convention that is just waiting for a disaster. You should never have slashes in your names, as this can cause serious problems within VBA. Underscores work perfectly well, and never get confused for another usage.

gburch:
Is there any way to make an Event Procedure conditional?
What do you mean by "conditional"? There may be some connotations or implications which you don't intend. But from a programming stance, all code is "conditional" from the sense that you test "conditions" to determine whether or not you want to execute any portion of code. In fact, you have much code above that is conditional, becuase you are using If...Then statements.

I don't know if that is what you are asking, but that is always how you control whether or not to execute any type of procedure/line of code.

Hope this hepps!
Mar 1 '19 #8
gburch
7 New Member
The problem I foresee with building an AfterUpdate Event for when the user updates before tabbing/entering/arrowing right, and building a LostFocus or other event for when the user tabs without updating, is that both will execute when the user does update. I need to test for a condition of Tab-Without-Update to execute the LostFocus event. I suspect this gets into the Access app itself and is not under a developer's control.

Thanks for the warnings about the "/" - I have been careful to [] all such references, but I can always learn a better way.
Mar 1 '19 #9
twinnyfo
3,653 Recognized Expert Moderator Specialist
Thus, you have uncovered one of the many challenges/weaknesses (Microsoft would call it a "feature") of using Sendkeys(). You would have to access the system's activity to see of a user were doing things without doing other things first.

Again, based upon what you are doing, you may be stuck with using SendKeys(). I've been trying to think of some alternate methods of displaying what you want to display by using the standard tools Access has made available to us....
Mar 1 '19 #10

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

Similar topics

2
by: nathanwalsh | last post by:
What are some of the differences between subforms and subreports? Here's my problem: I've got a form that lists a group of technicians. The main form lists basic information (name, job title, etc)...
3
by: Simone | last post by:
Hi All, I have a Find Record button setup in most of my forms in order to find a specific customer's details. I have just noticed today though that this search will only find the customer if it...
14
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ;...
6
by: dhowell | last post by:
I have a "form" and "subform" where I would like a calculated control on the form which sums the values of a datasheet column of the subform. (datasheet on subform may have a variable number of...
6
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
4
by: froglog | last post by:
I have created a MS access DB to track transport costs for tax purposes. I enter data into a main form that tracks miles traveled by date with a subform . The subform has fields for the date...
2
by: 09876 | last post by:
Hi: all I understand the difference between dynamic binding and static binding. But I just wonder what is the point to make the distinction between the dynamic binding and static binding. For...
2
by: cambar | last post by:
When Access db is first opened and the first record is entered, tabbing on subform works properly. However, when subsequent records are entered, the subform retains memory of the last field filled in...
1
by: Adam Tippelt | last post by:
Hi, I've got a form setup with a subform at the bottom of it. The window for the subform is big enough that the entire subform is visible without scrolling within the window, however the parent...
5
by: Whizbang1982 | last post by:
I am attempting to use this (http://www.lebans.com/conformscurcontrol.htm) in a continuous subform. I have a form with records, and a subform that displays records related to the parent record. I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.