How to reference n-1 or top one of a control (1 Viewer)

dgent81

New member
Local time
Today, 04:01
Joined
Jul 21, 2021
Messages
3
The control is a combobox (Patient) on a detail subform. As you make entry the grid automatically shows the user a new add row right below it with the controls repeated. A typical grid. I can reference the control they are touching using Me.Patient and that works fine, but I want to do like jQuery and other coding can do and talk to the control right above it if it is there with the same name. So if Me.Patient they are on is on row 3 (How to know is a question) then I want to be able to control the same control on the first row...Patient[1] or the row preceding Patient[3-1]

Access has to know which row the control is on and since the control name is the same there has to be a way to define the row or ask the lower bound or upper bound of the rows being shown in the detail pane of the subform. I realize this is not jQuery and maybe Access does not expose this to the VBA

My goal is to set the control that has gotFocus (Me.Patient) to the same selected option/id/name as the preceding control with the same name if row > 0 thus saving the user time and not requiring them to type in and find the same persons name in the list. The control has the same list of patients as it is based on the same query as it is the same control.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:01
Joined
Feb 19, 2013
Messages
13,373
think you need to provide examples of what you are talking about - when you say grid, do you mean datasheet view? or are you talking about the active x grid control?

If the former, you are using a sql query to populate the datasheet, consequently there is no concept of next/previous. In a datasheet or continuous form, there is only one row of controls - they are just repeated.

There are ways of creating row numbers etc, but your explanation of what you require is not sufficient to see which, if any, might work for you
 

dgent81

New member
Local time
Today, 04:01
Joined
Jul 21, 2021
Messages
3
Capture.JPG


I would say it is add records via a details area of a subform, but it sounds like access does not expose what I need at runtime of the form
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 12:01
Joined
Jul 9, 2003
Messages
13,430
Would my subform record duplicator be an option? See more here:-

 

dgent81

New member
Local time
Today, 04:01
Joined
Jul 21, 2021
Messages
3
Interesting thought as the first row is now in the database but the newly focused row/control is not yet in the databased. If I push a record into the database based on lostfocus, I wonder if the subform will realize that and show the new records. good test
 

Users who are viewing this thread

Top Bottom