Field to go to a specific record

On a form with multiple sub forms, I’d like to have a field that I can enter a record number in, and when I leave this field, go to the record specified in the master/main form record of the form.

Form navigator bar will do this. You could create a navigator bar as form control, write the row you want in the navigator bar and end with return.

Robert,
I’m well aware of that. The problem comes in when you have a subform selected and you need to go to a record in the master form. Thats why I would like a field dedicated for doing that.

Either you didn’t understand the solution offered by RobertG or we don’t understand your question. Each MainForm and SubForm can have it’s own Navigation Bar. In Design Mode select the MainForm then from the Form Controls menu select Navigation Bar and draw it somewhere on your form. In use you have a field that you can enter a record number in, and when you press Enter, go to the record specified in the master/main form record of the form.

I have a form that consists of a master form and two subforms.
I’d like a field on my form that when I enter a record number in it and execute it, it takes me to the record associated with the master form.

If you don’t want to use a navigtion bar (Form → Navigation Bar) you have to create a solution with a numeric field and a macro:

SUB JumpToRow(oEvent AS OBJECT)
oField = oEvent.Source.Model
oForm = oField.Parent
loRow = oField.CurrentValue()
oForm.absolute(loRow)
END SUB

Connect this macro to the event for losing focus of the numeric field and it will jump to the row.

Robert,
I’ll give it a try. Thanks

Before I attempt an answer, is the following description accurate? Change the selected record of the Mainform while maintaining the focus on the subform and without regard for the selected record of the subform. A seperate field control would not work for this as the subform is also a control so when entering the control to select the Mainform record, the subform would lose its focus. I will think a bit harder about this, but for now, I think RobertG’s independant form navigation bar suggestion is the most neglected option.

I use the navigation bar all the time, but if a subform is active, then when I enter a record#, it goes to the table associated with the subform not the master form. So I have to fiddle around to get to where I want to go, thus the desire for a way to enter a record to go directly to that record associated with the master form.
I created the field for moving to a row/record in the master form of the form, not a subform. So the act of doing that should select the table associated with the master form. Robert provided a macro that I have not tried implementing in that text field. Erik

Get the subform properties, tab “Data”.
Property “Navigation bar” = Parent

Villeroy,
I tried this, based on your suggestion, and the “record to go to” function (in the navigation bar) still operates as before. It tries to go that record in the active subform, not the parent. In my case, the parent could be two levels up, though. My form’s structure is Parent > Subform > Subform. I don’t know if that negates this approach. Erik

Whenever you navigate to another record in the parent form, the subform needs to be reloaded because the subform has another record set of related items than before. After reloading the form, the record cursor goes to record number 1 (if there is any record).

https://ask.libreoffice.org/uploads/short-url/mfOBkrnrtlTRV0Y0alhBmWedDFp.odb
Open the “Persons” form, focus the yellow tools and enter some record number in the toolbar (1 to 8 since there are 8 persons) in the main form. The main form jumps to the specified record number and reloads the tools belonging to the person.

I get that. The problem is when I have just entered data in a subform (so its active) and want to go to another parent record. So I go down to the nav bar and enter a record number and execute it (forgetting the problem with it) - going to that record in the subform if it exists. So I have then to screw around clicking the parent form and repeating the process. I’d just like to have a field where I enter a record number and always go to the parent record.

Robert,
I implemented the subroutine you provided and when I execute it I get a “BASIC runtime error. Variable not defined” on the second line which is
oField = oEvent.Source.Model.
I’m unsure how to define compound variables.
Would you be so kind to define the variable in your routine for me.
Also, I was unsure what event to assign it to execute the macro - I used “Mouse outside”. Id like it to execute when I click outside the textbox or press return.
Thanks Erik

Robert,
I was able to define the variables and get the routine to run. I’m very happy, thank you.
The second half of my previous message about not understanding the best event to assign the macro to (using a text box) still stands, as the execution of the macro seems inconsistent. Thanks again. Erik

Navigationbar: You could create a navigation bar as form field. If you create this navigation bar you create it in mainform and it will show the rows of the mainform - also when seeing the content of the subform.

Event for executing the macro: If you add the field to mainform and connect the macro to the event “When losing focus” of a numeric field you could enter a number and press “Return”. Form will be set to the row.

The most commonly used macro events for textboxes are - changed, when losing focus, mouse button released, and after updating. If using after updating, then the prerequisite variable oField = oEvent.Source. I use changed most often on textboxes. This means after entering data into the textbox, upon pressing enter or tabbing out of the textbox, if the data has been changed, then the macro is called.

Sky,
I moved the macro to Changed and it works great.
Thanks, Erik