Opening query(s)
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Opening query(s)
I open certain forms on a Db with code. Is there a methos to open queries as well?
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
Oops this should be in a new thread.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
In general, end users should never view tables and queries directly.
But if you really want to, just like you can open forms using DoCmd.OpenForm, you can open queries using DoCmd.OpenQuery.
But if you really want to, just like you can open forms using DoCmd.OpenForm, you can open queries using DoCmd.OpenQuery.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
Well I'm the only user, but thanks.
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
I do have a small issue with one of my Dbs. When the Db is opened there is a form that is loaded with the Application Options. I entered the following code into an OnLoad event of the form
The fir command opens that form in design view instead of Datasheet view(my preference)
Any suggestion to open that form in datasheet view? This an annoyance rather.
Code: Select all
Private Sub Form_Load()
DoCmd.OpenForm "frmTDAmeritradeExDates"
DoCmd.OpenQuery "quUpcomingExDates"
DoCmd.OpenQuery "quSymbolFilter"
End Sub
Any suggestion to open that form in datasheet view? This an annoyance rather.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
Try
DoCmd.OpenForm FormName:="frmTDAmeritradeExDates", View:=acFormDS
DoCmd.OpenForm FormName:="frmTDAmeritradeExDates", View:=acFormDS
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
If you want to be sure that a form is opened in Datasheet view, you can use this. If you want to open a form in Form view, use acNormal instead of acFormDS.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
Ok. Other questions in the same theme of opening.
What would be a code command to open the application with the navigation panel hidden?
What would be the code to open a form or query Top = XXX, Left = xxx. For my screen only not to be distributed.
What would be a code command to open the application with the navigation panel hidden?
What would be the code to open a form or query Top = XXX, Left = xxx. For my screen only not to be distributed.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
1) Click the big Office button, then click the Access Options button at the bottom.
Select Current Database.
Scroll down to the Navigation section.
Clear the check box Display Navigation Pane.
Click OK.
The database will now open with the navigation pane hidden.
Press F11 to unhide it.
2) Use code like
DoCmd.OpenForm FormName:="frmTDAmeritradeExDates", View:=acFormDS
Forms("frmTDAmeritradeExDates").Move Left:=400, Top:=300
No idea how to position a query.
Select Current Database.
Scroll down to the Navigation section.
Clear the check box Display Navigation Pane.
Click OK.
The database will now open with the navigation pane hidden.
Press F11 to unhide it.
2) Use code like
DoCmd.OpenForm FormName:="frmTDAmeritradeExDates", View:=acFormDS
Forms("frmTDAmeritradeExDates").Move Left:=400, Top:=300
No idea how to position a query.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
I viewed the property sheet of one of the forms and that had many more options than does the queries property sheet. The only items that had "relevance" was Grid X= 24 and Grid Y=24, but those values were on all forms, not on queries. There must be some hidden properties deep down, because each database that I have "remembers" where a particular form or query position was the last time a form or query was it was closed, as it opens where it existed the last time. The center property was set to no. I'll experiment and see what I learn.HansV wrote: ↑08 Apr 2023, 13:131) Click the big Office button, then click the Access Options button at the bottom.
Select Current Database.
Scroll down to the Navigation section.
Clear the check box Display Navigation Pane.
Click OK.
The database will now open with the navigation pane hidden.
Press F11 to unhide it.
2) Use code like
DoCmd.OpenForm FormName:="frmTDAmeritradeExDates", View:=acFormDS
Forms("frmTDAmeritradeExDates").Move Left:=400, Top:=300
No idea how to position a query.
Thanks
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
You can use the following code in the On Load event of the startup form to minimize (collapse) the navigation pane:
Code: Select all
DoCmd.SelectObject acModule, , True
DoCmd.Minimize
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
I received an error: object required
Code: Select all
DoCmd.SelectObject acModule, , True
DoCmd.Minimize
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Opening query(s)
How about
If that doesn't work either, I cannot help you.
Code: Select all
DoCmd.SelectObject acTable, , True
DoCmd.Minimize
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 564
- Joined: 27 Jun 2021, 10:46
Re: Opening query(s)
> "remembers" where a particular ... query position was
Are you quite sure? Queries have never been directly positionable, as far as I am aware. The normal 'trick' is to create a form based on the query, and set to Datasheet view
Are you quite sure? Queries have never been directly positionable, as far as I am aware. The normal 'trick' is to create a form based on the query, and set to Datasheet view
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
I'm not quite sure what you're asking of me. Am I sure that the queries open where they were in the last session? Yes, I'm sure
This is code attached to the form that opens when the Db is opened. The queries are where they were, the forms are where they were positioned.
Code: Select all
Private Sub Form_Load()
Me.Recordset.MoveLast
Me.[Tradedate].SetFocus
DoCmd.OpenForm FormName:="frmProfit", View:=acNormal
DoCmd.OpenForm FormName:="frmAction", View:=acFormDS
Me.Profit.Locked = False
DoCmd.OpenQuery "quDailyP/L"
DoCmd.OpenQuery "quP/L"
'DoCmd.SelectObject acModule, , True
DoCmd.Minimize
End Sub
-
- BronzeLounger
- Posts: 1412
- Joined: 08 Jul 2016, 18:53
Re: Opening query(s)
Changed to the above and seemed to work.HansV wrote: ↑12 Apr 2023, 09:21How about
If that doesn't work either, I cannot help you.Code: Select all
DoCmd.SelectObject acTable, , True DoCmd.Minimize