Results 1 to 5 of 5
  1. #1
    Datech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    40

    Help with a small query


    I want to make a query to display only bugs submitted by the current user. I've put in a text box that holds the value of the UserID, which is tied to the UserName of who submitted the bug. I'm having no luck getting this filter to work correctly though. Here's the SQL statement I'm using, and it's giving me nothing:

    Code:
    SELECT DISTINCTROW tblBugReport.BugNumber, tblBugReport.UserName AS [User], tblBugReport.Summary AS Summary, tblBugReport.Priority AS Priority, tblBugReport.Status AS StatusFROM tblBugReport
    GROUP BY tblBugReport.BugNumber, tblBugReport.UserName, tblBugReport.Summary, tblBugReport.Priority, tblBugReport.Status
    HAVING (((tblBugReport.UserName)=[Forms]![frmBugs].[txtUserID].[value]));
    txtUserID is the text box containing the user name info on the frmBugs form. The code that populates the text box works, the query doesn't. This query populates a list box that displays all the info in a nice little selectable column arrangement. I've made it work so that it will display all the bug report entries, just can't get it right to filter on user type.

    Thanks!
    Last edited by Datech; 05-10-2012 at 08:19 AM.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I've put in a text box that holds the value of the UserID, which is tied to the UserName
    txtUserID is the text box containing the user name info on the frmBugs form.
    Please show us an example of what exactly is in the txtUserId txtbox, and
    what is in UserName in the tblBugReport.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    SELECT DISTINCTROW tblBugReport.BugNumber, tblBugReport.UserName  AS [User], tblBugReport.Summary AS Summary, tblBugReport.Priority AS  Priority, tblBugReport.Status AS StatusFROM tblBugReport
    GROUP BY tblBugReport.BugNumber, tblBugReport.UserName, tblBugReport.Summary, tblBugReport.Priority, tblBugReport.Status
    HAVING (((tblBugReport.UserName)=[Forms]![frmBugs].[txtUserID].[value]));
    You need a space between Status and FROM


    You don't need "Value" >> [Forms]![frmBugs].[txtUserID].[value]
    Should be just : [Forms]![frmBugs].[txtUserID]

    Quote Originally Posted by Datech View Post
    I want to make a query to display only bugs submitted by the current user. I've put in a text box that holds the value of the UserID, which is tied to the UserName of who submitted the bug. I'm having no luck getting this filter to work correctly though.
    <snip>

    <snip>
    txtUserID is the text box containing the user name info on the frmBugs form. The code that populates the text box works, the query doesn't. This query populates a list box that displays all the info in a nice little selectable column arrangement. I've made it work so that it will display all the bug report entries, just can't get it right to filter on user type.
    Why are you using a totals query when you are not using an aggregate function?
    You might try:
    Code:
    SELECT DISTINCTROW tblBugReport.BugNumber, tblBugReport.UserName  AS [User], tblBugReport.Summary AS Summary, tblBugReport.Priority AS  Priority, tblBugReport.Status AS Status
    FROM tblBugReport
    WHERE tblBugReport.UserName = [Forms]![frmBugs].[txtUserID]
    ORDER BY tblBugReport.BugNumber, tblBugReport.UserName, tblBugReport.Summary, tblBugReport.Priority, tblBugReport.Status
    My $0.02

  4. #4
    Datech is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    40
    orange, an example of txtUserID is "dvanbeek", and UserName is "dvanbeek". That way I pull up all the BugNumber (ID for tblBugReports) where the associated UserName is equal to the logged in user. The logged in user's UserName is stored in the txtUserID field after a With statement sets a UserInfo variable in a recordset in the LogInForm. I know y'all don't have visibility for half that stuff, but I didn't think it was needed at first.

    The code that worked was:
    Code:
    SELECT DISTINCTROW tblBugReport.BugNumber, tblBugReport.UserName AS [User Name], tblBugReport.Summary AS Summary, tblBugReport.Priority AS Priority, tblBugReport.Status AS StatusFROM tblBugReport
    WHERE (((tblBugReport.UserName)=[Forms]![frmBugs]![txtUserID].[value]));
    The '.value' was apparently necessary (feel free to tell me why), and I should have used a WHERE instead of a HAVING. The lack of a space between the Status and FROM was a copy/paste error I believe. This is solved, but feel free to comment on the .value and the difference between a WHERE and HAVING if you want to educate me and any lurkers.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think Steve has the answer.

    I thought .value was the default ????

    HAVING see http://www.techonthenet.com/sql/having.php after aggregation
    Where is used before aggregation

    Glad this is resolved.

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

Similar Threads

  1. Need Help Building a small database
    By Darren in forum Access
    Replies: 1
    Last Post: 04-12-2012, 01:20 PM
  2. Field Is Too Small Issue
    By netchie in forum Forms
    Replies: 1
    Last Post: 09-21-2011, 12:45 PM
  3. small help needed
    By arthasdk in forum Access
    Replies: 3
    Last Post: 01-07-2011, 12:08 AM
  4. Small Business Question
    By P5C768 in forum Access
    Replies: 1
    Last Post: 09-28-2009, 08:27 AM
  5. small if statement help please
    By taylorosso in forum Programming
    Replies: 16
    Last Post: 09-23-2009, 11:23 AM

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