Navigation Forms (1 Viewer)

JonnieMorgan

New member
Local time
Today, 07:16
Joined
Aug 7, 2021
Messages
4
Hi All, newbie question, forgive me for not searching the forum for this first but I’m unsure of the terminology!



I have a form there is a Form_Current event that sets the focus to a txt box:-

Forms!frmMedBrowser!FocustxtBox.SetFocus

This works fine, however when I put this form into a Navigation Form I get an error saying it cant find the form, so I’m thinking it might have something todo with the (excuse my terminology here) referencing of the object so I added:-

Forms!NavigationForm!frmMedBrowser!FocustxtBox.SetFocus to the statement.



But as you can guess that doesn’t work, would some kind person point me in the direction of the answer please?

TIA

Jon
 

June7

AWF VIP
Local time
Yesterday, 22:16
Joined
Mar 9, 2014
Messages
3,730
Have to reference subforms through the subform container control. On regular form/subform arrangement I always name container different from object it holds, like ctrMed. When a Navigation Form is created, Access defaults with NavigationSubform, so try:

Forms!NavigationForm.NavigationSubform.Form.FocustxtBox.SetFocus

Access names the main form as Navigation Form - with a space. Did you change so space is removed?
 

JonnieMorgan

New member
Local time
Today, 07:16
Joined
Aug 7, 2021
Messages
4
Thank you. I see where I was wrong now! Not too far off was I! Yes I did delete the space.
Regards
Jon
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:16
Joined
May 7, 2009
Messages
14,648
If the "textbox" you want to setfocus is on the same form as the
current event:

just use Me.textbox.Setfocus, on the current event.
 

JonnieMorgan

New member
Local time
Today, 07:16
Joined
Aug 7, 2021
Messages
4
Even better, which leads me onto my next question. If I should start a new thread please tell me.
I have this FocusTxtBox on pretty much all my forms as it irritates me greatly otherwise. It would save me time if I could save and reuse the txtbox in other forms rather than creating a new one every time.

TIA
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:16
Joined
May 7, 2009
Messages
14,648
it can be done, but the problem is the placement of the textbox.
what is easier to do, is add a textbox and have a Class that
is reusable.
everytime Current event is triggered on the form, the textbox get focus.
 

Attachments

  • textbxFocus.accdb
    532 KB · Views: 117

JonnieMorgan

New member
Local time
Today, 07:16
Joined
Aug 7, 2021
Messages
4
Right OK thanks for the example. I think for now I will plod on with old faithful and come back to that part later on in my learning.

Thank you for your answers.

Jon
 

Users who are viewing this thread

Top Bottom