Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42

    Parameter query problem


    I have the following paramater query that is somewhat puzzling.

    PARAMETERS StartDate DateTime, EndDate DateTime;
    SELECT DISTINCT [Individual Donor Table].[Full Name], Sum([Individual Gift Amount Table].[Gift Amount]) AS [SumOfGift Amount]
    FROM [Individual Donor Table] INNER JOIN [Individual Gift Amount Table] ON [Individual Donor Table].[Full Name] = [Individual Gift Amount Table].[Full Name]
    GROUP BY [Individual Donor Table].[Full Name];

    It works fine without the first line. However, with that first line, I am asked for the Start and End Dates twice. How to I resolve this issue?

    john134

  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,641
    You don't use them, so why are they there at all? I'd expect 2 parameter prompts, one for StartDate and one for EndDate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    I'm slightly confused by your question. You are asked for StartDate twice and asked for EndDate twice?

    It appears that you are not using the parameters in your query it self? If so then why define them to begin with? Any time your query has PARAMETERS that means that access is going to prompt you for input for each variable defined in by the parameters, so it makes sense that it would ask you once for StartDate and once for EndDate.

  4. #4
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42
    Sorry, I didn't make myself clear. It asks for Start Date then End Date and then again
    Start Date and End Date. Each of the two parameters twice.

    John134

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Again, why not just take out the PARAMETERS clause, since you don't use them? I couldn't duplicate the issue, I only got prompted once each. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42
    Thank you for your reply, Paul. It is much appreciated.

    I use the parameters to filter the union query between two dates. Perhaps,
    there is a better way to do if you have any suggestions.

    I also had it working correctly the first time I queried but then the second
    and subsequent queries I got the issue described above.

    If you do not get the same results the second time around I will include the
    tables.

    John

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    If you get prompted twice, I'd wonder if the parameters were spelled differently. I don't see that you need them there anyway, and the PARAMETERS clause is optional for regular queries (not optional for crosstabs). What's the SQL of the other query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42
    I've checked the spelling and there are no typos. If I don't
    need the parameters how do I llimit the union query to a date
    range?

    Here is the SQL for the Union Query with the same problem.

    PARAMETERS [Start Date] DateTime, [End Date] DateTime;
    SELECT [Individual Donor Table].[Full Name], [Individual Gift Amount Table].[Gift Date], [Individual Gift Amount Table].[Gift Amount], [Individual Donor Table].ConfCode, [Individual Donor Table].[Street Address], [Individual Donor Table].City, [Individual Donor Table].State, [Individual Donor Table].ZIP, [Individual Donor Table].Telephone, [Individual Donor Table].[E-Mail]
    FROM [Individual Donor Table] INNER JOIN [Individual Gift Amount Table] ON [Individual Donor Table].[Full Name] = [Individual Gift Amount Table].[Full Name]
    GROUP BY [Individual Donor Table].[Full Name], [Individual Gift Amount Table].[Gift Date], [Individual Gift Amount Table].[Gift Amount], [Individual Donor Table].ConfCode, [Individual Donor Table].[Street Address], [Individual Donor Table].City, [Individual Donor Table].State, [Individual Donor Table].ZIP, [Individual Donor Table].Telephone, [Individual Donor Table].[E-Mail]
    HAVING ((([Individual Gift Amount Table].[Gift Date])>=[Start Date] And ([Individual Gift Amount Table].[Gift Date])<=[End Date]) AND (([Individual Donor Table].ConfCode)="D"))
    ORDER BY [Individual Donor Table].[Full Name], [Individual Gift Amount Table].[Gift Date]
    UNION SELECT [Organization Donor Table].[Org Name], [Organization Gift Amount Table].GiftDte, [Organization Gift Amount Table].[Gift Amount], [Organization Donor Table].ConfCode, [Organization Donor Table].[Street Address], [Organization Donor Table].City, [Organization Donor Table].State, [Organization Donor Table].ZIP, [Organization Donor Table].Telephone, [Organization Donor Table].[E-Mail]
    FROM [Organization Donor Table] INNER JOIN [Organization Gift Amount Table] ON [Organization Donor Table].[Org Name] = [Organization Gift Amount Table].[Organ Name]
    WHERE ((([Organization Gift Amount Table].GiftDte)>=[Start Date] And ([Organization Gift Amount Table].GiftDte)<=[End Date]));

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Do you see the problem?

    StartDate
    Start Date
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42
    No, I don't see both those items. I copied it into Word and did a Find on both
    words. The only one found was "Start Date."

    I see I have a WHERE clause in the last select statement which includes the
    Start Date and End Date words, but I don't have one in the first select statement.

    I will add a WHERE clause to the first select statement to see if that solves the problem, but I doubt it.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The ones without spaces came from your first post. Is that query no longer involved?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just a comment....

    John, you shouldn't use special characters in object names. You have a dash in the field for the email address: "E-Mail".
    Better is "EMail" or "E_Mail" (if you must separate the letters).


    Should never use spaces in object names; field names, query, form, report or module names.


    Your table names are very long, even without spaces. I aliased the names in the query:
    Code:
    PARAMETERS [Start Date] DateTime, [End Date] DateTime;
    SELECT IDT.[Full Name], IGAT.[Gift Date], IGAT.[Gift Amount],IDT.ConfCode, IDT.[Street Address], IDT.City, IDT.State, IDT.ZIP, IDT.Telephone, IDT.[E-Mail]
    FROM [Individual Donor Table] AS IDT INNER JOIN [Individual Gift Amount Table] AS IGAT ON IDT.[Full Name] = IGAT.[Full Name]
    GROUP BY IDT.[Full Name], IGAT.[Gift Date], IGAT.[Gift Amount], IDT.ConfCode, IDT.[Street Address], IDT.City, IDT.State, IDT.ZIP, IDT.Telephone, IDT.[E-Mail]
    HAVING (((IGAT.[Gift Date])>=[Start Date] And (IGAT.[Gift Date])<=[End Date]) AND ((IDT.ConfCode)="D"))
    ORDER BY IDT.[Full Name], IGAT.[Gift Date]
    UNION SELECT ODT.[Org Name], OGAT.GiftDte, OGAT.[Gift Amount], ODT.ConfCode, ODT.[Street Address], ODT.City, ODT.State, ODT.ZIP, ODT.Telephone, ODT.[E-Mail]
    FROM [Organization Donor Table] AS ODT INNER JOIN [Organization Gift Amount Table] AS OGAT ON ODT.[Org Name] = OGAT.[Organ Name]
    WHERE (((OGAT.GiftDte)>=[Start Date] And (OGAT.GiftDte)<=[End Date]));
    This is how to alias names:
    Code:
    FROM [Individual Donor Table] AS IDT INNER JOIN [Individual Gift Amount Table] AS IGAT ON IDT.[Full Name] = IGAT.[Full Name]
    
    FROM [Organization Donor Table] AS ODT INNER JOIN [Organization Gift Amount Table] AS OGAT ON ODT.[Org Name] = OGAT.[Organ Name]

    Good luck with your project.....

  13. #13
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42

    paramater query problem

    Quote Originally Posted by pbaldy View Post
    The ones without spaces came from your first post. Is that query no longer involved?
    These are separate queries, the first just to illustrate the problem. The names chosen aren't relevant since
    both have the same problem.

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Can you attach the db here, or a sample that prompts twice for each parameter?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    john134 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    42
    Here is the query:

    PARAMETERS [Start Date] DateTime, [End Date] DateTime;
    SELECT DISTINCT [Individual Donor Table].[Full Name], Sum([Individual Gift Amount Table].[Gift Amount]) AS [SumOfGift Amount]
    FROM [Individual Donor Table] INNER JOIN [Individual Gift Amount Table] ON [Individual Donor Table].[Full Name]=[Individual Gift Amount Table].[Full Name]
    GROUP BY [Individual Donor Table].[Full Name]
    UNION SELECT DISTINCT [Organization Donor Table].[Org Name], Sum([Organization Gift Amount Table].[Gift Amount]) AS [SumOfGift Amount]
    FROM [Organization Donor Table] INNER JOIN [Organization Gift Amount Table] ON [Organization Donor Table].[Org Name] = [Organization Gift Amount Table].[Organ Name]
    GROUP BY [Organization Donor Table].[Org Name];

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem with parameter query
    By jake7363 in forum Queries
    Replies: 1
    Last Post: 04-22-2016, 04:55 PM
  2. Replies: 3
    Last Post: 06-18-2015, 01:57 PM
  3. Parameter query problem
    By chrisfl in forum Queries
    Replies: 1
    Last Post: 08-17-2013, 12:06 AM
  4. Query parameter problem
    By Rzadziu in forum Queries
    Replies: 3
    Last Post: 03-30-2012, 01:57 PM
  5. Custom Query Parameter Prompts-- Problem
    By tylerthompson in forum Forms
    Replies: 11
    Last Post: 07-07-2009, 10:28 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