+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: access query displaying in the background

  1. #1
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    access query displaying in the background

    I have an access database and some designed user forms for use with the database.

    two of the form buttons run queries when clicked.

    the query window is popping up in the background behind the userforms as it runs and i do not want this to happen however I do not know how to stop it from happening.
    I am talking about the query window in standard access table view (if that makes sense)

    Can someone help me please.

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: access query displaying in the background

    Can you post the code you use to run the query?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    Here is the entire code for the button:

    Private Sub Find_Entry_Click()
    On Error GoTo Err_Find_Entry_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        DoCmd.OpenQuery "search"
    
        stDocName = "Results"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_Find_Entry_Click:
        Exit Sub
    
    Err_Find_Entry_Click:
        MsgBox Err.Description
        Resume Exit_Find_Entry_Click
        
    End Sub

  4. #4
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: access query displaying in the background

    The following line of code opens your query:

    DoCmd.OpenQuery "search"
    If you don't want the query to open, simply remove that line of code.

    If you want to run the query without opening it, use:

    CurrentDb.QueryDefs("search").Execute
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  5. #5
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    cheers,

    thanks for that

  6. #6
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    hey dave,

    I changed the code as you suggested however I now have another problem.

    When I click on the button that is supposed to execute the query and then open the results form I am getting an error message as follows:
    "Cannot execute a select query"

    Here is the 2 sets of query code:

    Query 1 - to find all duplicate entries in the database and display them:
    SELECT [Movie Database List].[Movie Title]
    FROM [Movie Database List]
    WHERE ((([Movie Database List].[Movie Title]) In (SELECT [Movie Title] FROM [Movie Database List] As Tmp GROUP BY [Movie Title] HAVING Count (*)>1)));
    Query 2 - to search for an entry in the database - this query is supposed to be usable with both partial AND full search criteria.
    SELECT [Movie Database List].Volume, [Movie Database List].[Movie Title], [Movie Database List].Rating, [Movie Database List].[Media Type], [Movie Database List].Collection
    FROM [Movie Database List]
    WHERE ((([Movie Database List].Volume) Like "*" & Forms!search.volume & "*") And (([Movie Database List].[Movie Title]) Like "*" & Forms!search.title & "*") And (([Movie Database List].Rating) Like "*" & Forms!search.rating & "*") And (([Movie Database List].[Media Type]) Like "*" & Forms!search.[media type] & "*") And (([Movie Database List].Collection) Like "*" & Forms!search.collection & "*"));
    Looking at the SQL code view that I can now see here I assume this has something to do with the "SELECT" at the beginning of the queries however I do not know what to do with this now.

    These sets of query code came from the original project that I was doing that had some issues and I have now began to re-design it.
    The main design is still basically the same so the coding should still work, however I did not copy the code from within an SQL code view, I copied it from the design view window in office 2003 where u can see the check box and the criteria field etc.

  7. #7
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: access query displaying in the background

    What was your query accomplishing in your original code? Since it was just a SELECT query, all it did was open the query. If you didn't want it to be opened, just remove that line of code.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  8. #8
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    in the original code it was accomplishing the exact same thing as it is now supposed to do.

    OK I will try removing the select line and see if it works then.

  9. #9
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    OK

    I removed the select line from the code so it now looks like this:
    FROM [Movie Database List]
    WHERE ((([Movie Database List].Volume) Like "*" & Forms!search.volume & "*") And (([Movie Database List].[Movie Title]) Like "*" & Forms!search.title & "*") And (([Movie Database List].Rating) Like "*" & Forms!search.rating & "*") And (([Movie Database List].[Media Type]) Like "*" & Forms!search.[media type] & "*") And (([Movie Database List].Collection) Like "*" & Forms!search.collection & "*"));
    and as soon as I tried to save it I get an error message window popup that says:
    Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' or 'UPDATE'.

    I have no idea what is going on. I never had these problems wit the code from the original project at all but the original project was giving me out of memory erros and things like that while trying to open forms and perform actions AFTER I had added more elements to the project.

  10. #10
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    I have a further query as well.

    There are 3 different searches possible within my program.

    1. Entering search criteria to search for individual entries.

    2. Clicking a button that will show only duplicated entries within the database.

    3. Clicking a button that then displays ALL the entries in the database.

    When clicking on these buttons it opens a form that displays entries in continuous view down the page.

    My query is whether or not I can have the one form for all 3 different search types and also whether or not that form can be made lockable and unlockable and also whether or not edit and delete buttons can be added to this form?
    I need the database to be non-editable unless specified otherwise but also need to be able to edit or delete records at various times.

  11. #11
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    anyone with any ideas at all about this problem?

  12. #12
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: access query displaying in the background

    What was the query doing??? You're code opened a query, but you say you didn't want the query opened. Just remove the line as shown below and it won't open the query.

    Private Sub Find_Entry_Click()
    On Error GoTo Err_Find_Entry_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        'DoCmd.OpenQuery "search" <-- Remove this line!
    
        stDocName = "Results"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_Find_Entry_Click:
        Exit Sub
    
    Err_Find_Entry_Click:
        MsgBox Err.Description
        Resume Exit_Find_Entry_Click
        
    End Sub
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  13. #13
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: access query displaying in the background

    Quote Originally Posted by vampyr07au View Post
    My query is whether or not I can have the one form for all 3 different search types and also whether or not that form can be made lockable and unlockable and also whether or not edit and delete buttons can be added to this form?
    I need the database to be non-editable unless specified otherwise but also need to be able to edit or delete records at various times.
    Yes these things can be done using VBA coding.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  14. #14
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    Dave,

    I already removed the open query line and changed it to the execute line as per your previous instructions.

    After I did this the project then told me I cannot execute a "select" query.

    so then - as suggested by you I removed the "select" line and then I get the following error as previously stated:
    "and as soon as I tried to save it I get an error message window popup that says:
    Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' or 'UPDATE'. "

    I have no idea what this problem is or whats causing it.

  15. #15
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: access query displaying in the background

    Quote Originally Posted by davegugg View Post
    Yes these things can be done using VBA coding.
    but can this all be done using just one form for results to be displayed or do I need seperate forms ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0