|
Subject:
|
Setting Query Focus.
|
|
Posted By:
|
eusanpe
|
Post Date:
|
6/2/2008 1:32:31 PM
|
Hello all:
I have a form that opens up named "Order_Form". I have it setup as a Popup in the form properties and I have it maximized on Form Open. I have a Lookup command button on it. When I click 'Lookup' then the code listed below runs and a read-only datasheetview window opens. The problem is that is opens in the background and I need it to open in the foreground. How do I bring it to the forefront either maximized or not and have the Order_Form in the background?
My code: ================================================= Private Sub cmdSearchOrders_Click() Dim db As Database Dim QD As QueryDef Dim where As Variant Set db = CurrentDb() On Error Resume Next db.querydefs.Delete ("Orders_Dynamic_Query") On Error GoTo 0
where = Null If Not IsNull(Me![scboOrderName]) Then where = where & " AND [OrderName] = '" + Me.scboOrderName + "'" End If If Not IsNull(Me![scboOrderType]) Then where = where & " AND [OrderType] = '" + Me.scboOrderType + "'" End If Set QD = db.CreateQueryDef("Orders_Dynamic_Query", _ "Select * from Orders " & (" where " + Mid(where, 6) & ";")) DoCmd.OpenQuery "Orders_Dynamic_Query", , acReadOnly End Sub
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
6/4/2008 7:18:52 AM
|
I think the problem is that you have your main form set to both Pop Up and to Maximize. Set Pop Up to No, and leave the maximize, and the datasheet will cover the main form since it will mazimize as well. To prevent this, put the datasheet in a Datasheet form, and set that form to Pop Up = Yes.
So Main form: Pop Up = No On Open = Me.Maximize
New Datasheet View form: Pop Up = Yes
The main form will function as it does now, but will not cover your new form. Your new form will prevent the query results from maximizing and covering your main form.
Did that help?
mmcdonal
Look it up at: http://wrox.books24x7.com
|
|
Reply By:
|
eusanpe
|
Reply Date:
|
6/4/2008 9:01:14 AM
|
mmcdonal:
Thank you for all of your help. I am just about finished with this project. You have been a godsend with your advice and knowledge.
As far as the form. I don't mind the datasheet covering the Main Form.That is what I want. After they look at the query result on the datasheet I want them to close it and the Main Form will be there. I will try what you said and let you know. I only made the for a popup because I didn't want the menus listed.
|
|
Reply By:
|
eusanpe
|
Reply Date:
|
6/4/2008 10:13:38 AM
|
I just left it as it was and changed the popup to 'no' and left it maximized. It worked great like that once I removed the menus.
With this format, can a subdatasheet be added to this dynamic datasheet and linked to child and master fields via vba?
Thanks for all of your help.
Tony
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
6/4/2008 10:20:45 AM
|
I am not sure if you can add a datasheet to a datasheet. I have never done that.
mmcdonal
Look it up at: http://wrox.books24x7.com
|