Results 1 to 3 of 3
  1. #1
    Zerdan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2011
    Posts
    15

    DCount Causing Form to Stall

    I've got a form that allows a user to enter search parameters and then click "search" which opens a second form to display the results of a query based on the search parameters. In the header of the results form I want a text box called total results that contains the number of results of the query.



    I've tried to do this with DCount("*", "Query Name") and when I open the form it says "Calculating..." in the lower left and just stalls out.

    I'm thinking maybe I need to calculate the total with the parameters that were used to search (but then how do I pass that number to my textbox?)

    Or maybe I can recalculate some other way on the form, but I can't get it to work without stalling on the Calculating...

    Thanks.

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,173
    Hi,

    there are several options you can use like using the .recordcount property of the forms recordset clone.
    But if you want to do it with a Dcount and without any VBA code, I would suggest you use the where clause in the DCount function to repeat the selection criteria; example:

    DCount("*", "Tablename","Field1 = " & Forms![FormName]![Name CritField1])

    assuming Field1 is a numeric field, of course

    Hope this helps
    NG

  3. #3
    Zerdan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2011
    Posts
    15
    Thanks for the info. Recordcount sounds like the way I want to do it reading into it a little bit more. A couple questions about that...

    How do I set my RecordSet? Right now I'm just passing my parameters from the search form to DoCmd.OpenForm and then running my query from there and populating the Results Forms with the filtered results.

    Once I have my RecordSet established, where do I put the code...like what should my Private Sub be named? Sorry for the questions, I am new to VB.

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

Similar Threads

  1. Blank column causing errors on import
    By brickballer in forum Import/Export Data
    Replies: 7
    Last Post: 05-20-2011, 12:54 PM
  2. Dsum causing speed issue
    By ethoemmes in forum Queries
    Replies: 0
    Last Post: 07-06-2010, 05:22 AM
  3. Form Filter Causing slight problem
    By cowboy in forum Forms
    Replies: 3
    Last Post: 04-15-2010, 07:32 AM
  4. vbCrLf is causing square box on last line
    By cowboy in forum Programming
    Replies: 1
    Last Post: 03-24-2010, 10:01 AM
  5. Replies: 1
    Last Post: 07-30-2009, 12:54 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