Open Query in Design View from Button on Form (?)

C

croy

I have managed to get a command button on a form to open a
query in design view for me, but the query does not keep the
focus. I can't seem to figure out how to shift the focus to
the query.
 
F

fredg

I have managed to get a command button on a form to open a
query in design view for me, but the query does not keep the
focus. I can't seem to figure out how to shift the focus to
the query.


Are you sure you wish to let users fiddle around with a query?

DoCmd.OpenQuery "QueryName", acDesign
works for me, displaying the query by example grid with the focus.

Perhaps you have some other code that moves the focus elsewhere.
 
C

croy

On Wed, 20 May 2009 16:18:37 -0700, fredg

Thanks for the reply Fred. My replies inline...
Are you sure you wish to let users fiddle around with a query?

Yes. It's for the boss--a senior biologist.

We have a barrel-full of analytical queries, many in series,
and I'm trying to reduce some of the confusion by making a
form that is somewhat like a map. Each query name is on a
button that will open it that query in data view for a
left-click, or design view for a right-click.
DoCmd.OpenQuery "QueryName", acDesign
works for me, displaying the query by example grid with the focus.

My code:

*****
Private Sub cmdqryY_M_S_TtlHrs_RA_MouseDown(Button As
Integer, Shift As Integer, X As Single, Y As Single)

Dim stDocName As String
stDocName = "qryY_M_S_SpHrs_RA"

If Button = acLeftButton Then
DoCmd.OpenQuery stDocName, acNormal, acEdit
End If

If Button = acRightButton Then
DoCmd.OpenQuery stDocName, acDesign
End If

End Sub
*****

It opens the query in design view, but the form retains the
focus, and a popup for it appears--the one with filtering
and sorting options, and at the bottom, "Properties". I
have to click on the query to give it the focus--not very
clean.
Perhaps you have some other code that moves the focus elsewhere.

Nope. Brand new form with no code for the form itself, just
code for a gaggle of buttons.
 
C

croy

On Wed, 20 May 2009 16:18:37 -0700, fredg

Once again, I forgot to mention that this is Access 2002, on
a WinXPProSP3 machine.
 
F

fredg

On Wed, 20 May 2009 16:18:37 -0700, fredg

Thanks for the reply Fred. My replies inline...


Yes. It's for the boss--a senior biologist.

We have a barrel-full of analytical queries, many in series,
and I'm trying to reduce some of the confusion by making a
form that is somewhat like a map. Each query name is on a
button that will open it that query in data view for a
left-click, or design view for a right-click.


My code:

*****
Private Sub cmdqryY_M_S_TtlHrs_RA_MouseDown(Button As
Integer, Shift As Integer, X As Single, Y As Single)

Dim stDocName As String
stDocName = "qryY_M_S_SpHrs_RA"

If Button = acLeftButton Then
DoCmd.OpenQuery stDocName, acNormal, acEdit
End If

If Button = acRightButton Then
DoCmd.OpenQuery stDocName, acDesign
End If

End Sub
*****

It opens the query in design view, but the form retains the
focus, and a popup for it appears--the one with filtering
and sorting options, and at the bottom, "Properties". I
have to click on the query to give it the focus--not very
clean.


Nope. Brand new form with no code for the form itself, just
code for a gaggle of buttons.

My best guess is that your form itself is being opened as a Pop-Up
form and therefore it will always be on top.
Change the Form's Pop-up property to No.
 
C

croy

My best guess is that your form itself is being opened as a Pop-Up
form and therefore it will always be on top.
Change the Form's Pop-up property to No.

I'm now thinking that it has something to do with the
*right* click. There must be an unmoveable function to
that.

It's looking like I need a mouse-keyboard combination to get
an alternate function for the left-mouse button. I'm
currently trying to find out how to do that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top