Results 1 to 13 of 13
  1. #1
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20

    Question Open Query result want to hide

    "DoCmd.OpenQuery "q_RemovedItems" this is a command line. "q_RemovedItems" is a Select query. At the time of execution it showing its view but I want to hide it's view.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Why are you opening it at all?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    for execution. is there any other method to execute it. The working method is-
    First step data from excel sheet imported in one table.
    In second step of sorting these select query will fire on the respective table where data imported from excel is present.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I repeat Paul's question - why open a SELECT query if you are just going to hide it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    It is used to filter out some data from table by using where clause for condition.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That still doesn't explain why you want to open then hide. What purpose does it serve to open a SELECT query if can't view the data on it?

    If the query is used as the RecordSource for a form or report, there is no reason to open the query, just open the form or report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    That select query used to remove the some records whose some fields are blank. Where clause used for condition

    Dim str1 As String
    str1 = "SELECT count(*) as counts FROM ImportDailyRedum;"
    DoCmd.SetWarnings False
    Set rst = CurrentDb.OpenRecordset(str1)
    TotalRecords = rst!counts
    rst.Close
    Set rst = Nothing

    DoCmd.OpenQuery "q_RemovedItems"

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Why did you post this code? It does not clarify the situation. Opening and closing a recordset in VBA has nothing to do with opening a query object.

    SELECT query does not remove records - records are still in the table - query just filters the records.

    What is TotalRecords - a variable or a field?

    SetWarnings is not needed because not running an action SQL (UPDATE, DELETE, INSERT).

    Should always SetWarnings back to True after completing procedure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    Is that you want to executing delete statement from a saved query, but don't want the query to open for user?

    Why recordset is used?

  10. #10
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    yes.. executing delete statement. the result data I will shift into another table. I don't want query to open for user.

    I will explain again..

    I have imported data in one table. I want to delete some data from the table. For that purpose I write one select query named as "q_RemovedItems". I write the code line below -

    "DoCmd.OpenQuery "q_RemovedItems"

    At the time of execution Query get opened which I don't required. that query is saved in list of queries of access object.

  11. #11
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    Quote Originally Posted by rmayur View Post
    yes.. executing delete statement. the result data I will shift into another table. I don't want query to open for user.

    I will explain again..

    I have imported data in one table. I want to delete some data from the table. For that purpose I write one select query named as "q_RemovedItems". I write the code line below -

    "DoCmd.OpenQuery "q_RemovedItems"

    At the time of execution Query get opened which I don't required. that query is saved in list of queries of access object.
    SELECT query is not for deleting the records, its for selecting. you need to make a delete query if you want to remove. What statement you have used in "q_RemovedItems" SELECT or DELETE?

  12. #12
    rmayur is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Location
    Mumbai
    Posts
    20
    SELECT ImportDailyRedum.[Transaction Date], ImportDailyRedum.[Admin Site Order Id], ImportDailyRedum.[New Member Site Order ID], ImportDailyRedum.[Reward Title], ImportDailyRedum.[Variation SKU], ImportDailyRedum.[Variation Title], ImportDailyRedum.[Redemption Partner], ImportDailyRedum.[Redemption Category], ImportDailyRedum.[Unit Point Cost], ImportDailyRedum.[Redemption Quantity], ImportDailyRedum.[Points Redeemed on Reward], ImportDailyRedum.[Fulfilment Method], ImportDailyRedum.[Redemption Status], ImportDailyRedum.[Additional Field], ImportDailyRedum.[Business ID], ImportDailyRedum.[Business Name], ImportDailyRedum.[Contact First Name], ImportDailyRedum.[Contact Last Name], ImportDailyRedum.[Address 1], ImportDailyRedum.[Address 2], ImportDailyRedum.[Address 3], ImportDailyRedum.[County/State], ImportDailyRedum.[Postcode/Zip], ImportDailyRedum.Country, ImportDailyRedum.[Contact Login], ImportDailyRedum.[Contact Email Address], ImportDailyRedum.contact_phone_number, ImportDailyRedum.[Current Enrollment Status], ImportDailyRedum.[Current MembershipTier]
    FROM ImportDailyRedum
    WHERE (((ImportDailyRedum.[Contact First Name])='\n')) OR (((ImportDailyRedum.[Contact Last Name])='\n')) OR (((ImportDailyRedum.[Postcode/Zip])='\n') or ((ImportDailyRedum.contact_phone_number) Is Null)) OR (((ImportDailyRedum.contact_phone_number)='\n'));

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't save a DELETE query object then there is no chance for user to run or see it. Can do the DELETE action in VBA.

    CurrentDb.Execute "DELETE FROM ImportDailyRedum WHERE [Contact First Name]='\n' OR [Contact Last Name]='\n' OR [Postcode/Zip]='\n' OR contact_phone_number Is Null OR contact_phone_number='\n'"

    What do you mean by "the result data I will shift into another table"?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Open form to first query result
    By Cheryl R in forum Forms
    Replies: 6
    Last Post: 06-22-2013, 07:26 AM
  2. Replies: 2
    Last Post: 02-13-2013, 04:14 PM
  3. Replies: 1
    Last Post: 06-08-2012, 11:14 AM
  4. Open report from query result
    By shank in forum Programming
    Replies: 11
    Last Post: 10-04-2011, 12:59 PM
  5. Use query result to open form.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-12-2011, 11:18 PM

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