on doubleclick, change focus (1 Viewer)

eibyer_apc

New member
Local time
Today, 00:22
Joined
Mar 1, 2022
Messages
14
I have a form with a text box that displays query numbers. I have it set to open the query on double click and that works. I just want to change the focus after the double click event so that the text box is not selected, maybe shift focus on the main form?

This is after the double click event.
1649096302747.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:22
Joined
Oct 29, 2018
Messages
18,987
Have you tried setting the focus to a different control? You can either use DoCmd.GoToControl or Me.ControlName.SetFocus to do that.
 

eibyer_apc

New member
Local time
Today, 00:22
Joined
Mar 1, 2022
Messages
14
That did it! Thank you. Just had to make sure to do the setfocus before my docmd.openquery.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:22
Joined
Oct 29, 2018
Messages
18,987
That did it! Thank you. Just had to make sure to do the setfocus before my docmd.openquery.
Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:22
Joined
Feb 19, 2002
Messages
36,327
Opening queries that users can interact with is as dangerous as it gets. It is really poor practice. Users should only see forms or reports. That way you have events that can be used to control what updating is acceptable and perform proper validation. When you let users open naked queries, they can do whatever they want if the query is updateable.

A form in DataSheet view is almost as flexible as a query if you want to allow the user filtering and sorting options.
 

eibyer_apc

New member
Local time
Today, 00:22
Joined
Mar 1, 2022
Messages
14
Noted. I'm the only user for now so I'm not worried about that part yet. If I get comfortable enough to create a project that involve other users then I would definitely try to avoid displaying the query and instead present a datasheet view form that actually makes more sense now that you pointed it out :)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:22
Joined
Feb 19, 2002
Messages
36,327
I can be just as sloppy as the next guy (gal) so even when building for myself, I try to do it "right".
 

Users who are viewing this thread

Top Bottom