• IIF() possibly causing database to crash (Access 2002)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » IIF() possibly causing database to crash (Access 2002)

    Author
    Topic
    #403159

    help
    This one’s a doozy. I’m working on a database and getting a serious error that keeps causing the database to crash. I have two queries in this database (these two queries are the whole reason the database was created), and both use IIF() statements. The queries are also fairly deeply embedded, using two or three other queries to calculate values beforehand. The first time I created & ran these queries, they worked fine. Now if I try to run, modify or even open the queries in Design view, the database crashes & Access closes completely, but leave the *.ldb file open. Does anyone have any thoughts as to why this might be? I can provide more details, if necessary. If anyone has any thoughts, comments, etc., I would greatly appreciate the help. I’m going insane trying to get this one finished! hairout
    Thank you!
    Stacy

    Viewing 1 reply thread
    Author
    Replies
    • #808342

      Welcome to Woody’s Lounge!

      1. Can you open the queries in design view after a Compact and Repair of the database?
      2. Can you open the queries in design view after importing all database objects into a blank new database?

      If not, could you provide more details about the design of the queries?

      • #808384

        Thank you for the welcome!
        To answer your questions:
        1. No, I have Compacted & Repaired several times & this has not made a difference
        2. I tried to export everything to a new database today and the new database still crashed when I tried to run the queries.
        Okay, here’s a breakdown of the database:
        The main table is a project information table. Amoung other bits of data, there is a win percentage. I then created a couple of other tables which I made into child tables by embedding their forms in the project information form. They are linked by a unique project ID which is created using an autonumber. The primary child table allows the user to enter the last day of a particular month, estimated revenue for that month & actual revenue (estimates & actuals are two separate fields). I created two queries that weighted the actuals & estimates by multiplying them by the win percentage. I then took these two queries and created a new select query (qryMRAMRE) that used the IIF() with parameters. The IIF() goes something like this:
        IIF([Month]< [Enter first day after last day of actuals reporting period],[WeightedActuals],IIF([Month]>[Enter first day of estimates reporting period],[WeightedEstimates],Null)
        Anything in blue is a parameter and [Month] is actually entered as the last day of the month (i.e., 01/31/04). I did a similar IIF() to pull back the appropriate month. I did this so that I could create a crosstab (qryMRAMRECrosstab) where each project line would produce actuals before a certain date & estimates after that same date all on the same line. The crosstab is pivoted by month. This is the first query that keeps crashing.
        The second query took the qryMRAMRE query and created another crosstab (qrySalesCrosstab) that summed all of a project’s revenue (actuals before a certain date & estimates after) and put them under a month column that corresponded back to the project start date. Since project start dates can vary, I created a query to pull Month() and then another query to get MonthName(). I then combined these two to get the header YYYY-MM-Month (e.g., 2004-01-January) and used that new combined field as the column header in the qrySalesCrosstab query. The qrySalesCrosstab also causes the db to crash.
        Phew, I think I included everything that was really important. I also did some tables for easy upkeep of certain values for certain drop-down fields, but those were pretty simple. I hope that description makes sense.
        Would it be helpful to attach a copy of the database?

        • #808398

          Yes, attach a zipped copy of your database.

          • #808908

            Okay, I had to trim a lot out of this database (mostly forms & macros) to get it under 100K. The original is sadly about 300K when zipped. In any event, the queries causing trouble are qryMRAMRE, qryMRAMRECrosstab & qrySalesCrosstab.
            Thanks again for taking a look at this.

            • #809065

              I have tried to execute the queries and tried to open them in design view, but NO GO.
              I also tried to import the tables and queries to a new database, but the problem still persists.
              All your other queries seem to work ok.
              Why don’t you delete the bad queries and reconstruct them and see what happens.
              Do you want to post the SQL of those queries so we can see what you are doing.

              Other than that, I cannot help you.

            • #809134

              The parameters in your queries are much too long, Access chokes on them. Either shorten the prompt texts significantly, or create a form with text boxes in which the user can enter the relevant dates, and use these as parameters.

            • #809135

              The parameters in your queries are much too long, Access chokes on them. Either shorten the prompt texts significantly, or create a form with text boxes in which the user can enter the relevant dates, and use these as parameters.

            • #809160

              To amplify on Hans’ point, the maximum number of characters for a parameter in a parameter query is 255 (for Access 2002).

            • #809198

              The parameters are well below 255 characters, but still, I found that making them shorter prevented Access from crashing.

            • #809161

              To amplify on Hans’ point, the maximum number of characters for a parameter in a parameter query is 255 (for Access 2002).

            • #809204

              Completely off-topic: here is a non-distorted version of your userpic.

            • #810968

              Okay, I just logged in after a 3 day weekend and all I can say is, wow. I think shortening the parameter input text worked. We’re testing it with data tomorrow. I’ll let you know if it works with live data. Thank all of you so much for your help. clapping

              Oh, and Hans, regarding my user pic…that’s what it originally looked like when I cropped it to the appropriate size. I think it distorts because of the orientation. I’m going to take another look at it. Thank you, though.

            • #810969

              Okay, I just logged in after a 3 day weekend and all I can say is, wow. I think shortening the parameter input text worked. We’re testing it with data tomorrow. I’ll let you know if it works with live data. Thank all of you so much for your help. clapping

              Oh, and Hans, regarding my user pic…that’s what it originally looked like when I cropped it to the appropriate size. I think it distorts because of the orientation. I’m going to take another look at it. Thank you, though.

            • #809205

              Completely off-topic: here is a non-distorted version of your userpic.

          • #808909

            Okay, I had to trim a lot out of this database (mostly forms & macros) to get it under 100K. The original is sadly about 300K when zipped. In any event, the queries causing trouble are qryMRAMRE, qryMRAMRECrosstab & qrySalesCrosstab.
            Thanks again for taking a look at this.

        • #808399

          Yes, attach a zipped copy of your database.

      • #808385

        Thank you for the welcome!
        To answer your questions:
        1. No, I have Compacted & Repaired several times & this has not made a difference
        2. I tried to export everything to a new database today and the new database still crashed when I tried to run the queries.
        Okay, here’s a breakdown of the database:
        The main table is a project information table. Amoung other bits of data, there is a win percentage. I then created a couple of other tables which I made into child tables by embedding their forms in the project information form. They are linked by a unique project ID which is created using an autonumber. The primary child table allows the user to enter the last day of a particular month, estimated revenue for that month & actual revenue (estimates & actuals are two separate fields). I created two queries that weighted the actuals & estimates by multiplying them by the win percentage. I then took these two queries and created a new select query (qryMRAMRE) that used the IIF() with parameters. The IIF() goes something like this:
        IIF([Month]< [Enter first day after last day of actuals reporting period],[WeightedActuals],IIF([Month]>[Enter first day of estimates reporting period],[WeightedEstimates],Null)
        Anything in blue is a parameter and [Month] is actually entered as the last day of the month (i.e., 01/31/04). I did a similar IIF() to pull back the appropriate month. I did this so that I could create a crosstab (qryMRAMRECrosstab) where each project line would produce actuals before a certain date & estimates after that same date all on the same line. The crosstab is pivoted by month. This is the first query that keeps crashing.
        The second query took the qryMRAMRE query and created another crosstab (qrySalesCrosstab) that summed all of a project’s revenue (actuals before a certain date & estimates after) and put them under a month column that corresponded back to the project start date. Since project start dates can vary, I created a query to pull Month() and then another query to get MonthName(). I then combined these two to get the header YYYY-MM-Month (e.g., 2004-01-January) and used that new combined field as the column header in the qrySalesCrosstab query. The qrySalesCrosstab also causes the db to crash.
        Phew, I think I included everything that was really important. I also did some tables for easy upkeep of certain values for certain drop-down fields, but those were pretty simple. I hope that description makes sense.
        Would it be helpful to attach a copy of the database?

    • #808343

      Welcome to Woody’s Lounge!

      1. Can you open the queries in design view after a Compact and Repair of the database?
      2. Can you open the queries in design view after importing all database objects into a blank new database?

      If not, could you provide more details about the design of the queries?

    Viewing 1 reply thread
    Reply To: IIF() possibly causing database to crash (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: