Results 1 to 3 of 3
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Create Query But Do Not Open Results

    I am using VBA to create a query, but the issue I have is that when this is completed thet query is opened on screen. How can I create teh query, but not have the query be opened, but just reside in memory to be called later?
    Code:
    Dim empName As String, strsql As String, qdf As QueryDef
    
    
    empName = Me.combobox1.Column(1)
    
    
    strsql = "Select * FROM helperDB where empName = " & empName & ";"
    
    
    Set qdf = CurrentDb.CreateQueryDef("NewQuery", strsql)
    DoCmd.OpenQuery qdf.Name


  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Code:
    Dim empName As String, strsql As String, qdf As QueryDef
    
    
    empName = Me.combobox1.Column(1)
    
    
    strsql = "Select * FROM helperDB where empName = " & empName & ";"
    
    Set qdf = CurrentDb.CreateQueryDef("NewQuery", strsql)
    qdf.SQL=strsql

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    I knew there was a simpler way of achieving this. Thank you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-05-2016, 09:07 AM
  2. Replies: 1
    Last Post: 04-01-2015, 09:45 AM
  3. Create Message Box based on query results
    By stanley721 in forum Queries
    Replies: 7
    Last Post: 02-14-2013, 10:04 AM
  4. Replies: 12
    Last Post: 12-17-2010, 05:35 PM
  5. Open form based on query results
    By RobbertH in forum Queries
    Replies: 1
    Last Post: 02-10-2010, 08:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums