Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2008, 01:32 PM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default Setting Query Focus.

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

 
Old June 4th, 2008, 07:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old June 4th, 2008, 09:01 AM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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.

 
Old June 4th, 2008, 10:13 AM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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

 
Old June 4th, 2008, 10:20 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Text Box Focus sathish_reddy ASP.NET 1.0 and 1.1 Professional 1 November 22nd, 2006 02:26 AM
Setting Focus on a Sub Form Brendan Bartley Access 1 August 8th, 2005 02:41 AM
Setting the Focus BSkelding ASP.NET 1.0 and 1.1 Professional 1 May 12th, 2005 01:40 PM
Trouble setting focus in textbox on tabpage katsarosj VB.NET 2002/2003 Basics 2 April 6th, 2005 11:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.