Results 1 to 3 of 3
  1. #1
    jones is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    17

    Red face Crosstab query criteria for command button

    Good day to all,



    I'm new in ACCESS DATABASE user and i find difficulties in linking the crosstab tab query into drop down list and command button.

    As you can see in my attachment, that i have a form then in my drop down list (project code)i want to filter my crosstab query by what is in current dropdown list value and i click the command button MsP then the datasheet will come up that is what i want.

    But the problem is in design view for crosstab query criteria, i can input the [form]![frm RSC Project]![Combo0] but when i try to run it, it say access database does not recognize as a valid name or expression. If anayone can advice me what to do i really really appreciate it, thanks in advance.

    Plaese see the attachment file.
    Attached Files Attached Files
    Last edited by jones; 03-21-2012 at 07:16 AM.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This is a known Access bug - it cannot be done.

    Replace the macro with the following code:
    Private Sub Command14_Click()

    Dim sqlstr As String, qdf As QueryDef
    On Error Resume Next
    DoCmd.DeleteObject acQuery, "testy"
    On Error GoTo errx

    sqlstr = "TRANSFORM Sum([tbl MsP vs PR:PO].[Qty Req'd]) AS [SumOfQty Req'd] " & _
    "SELECT [tbl MsP vs PR:PO].[Project Code], [tbl MsP vs PR:PO].[Resource ID], [tbl MsP vs PR:PO].Description, Sum([tbl MsP vs PR:PO].[Qty Req'd]) AS Total " & _
    "FROM [tbl MsP vs PR:PO] WHERE ((([tbl MsP vs PR:PO].[Project Code]) = '" & Me!Combo0 & "')) " & _
    "GROUP BY [tbl MsP vs PR:PO].[Project Code], [tbl MsP vs PR:PO].[Resource ID], [tbl MsP vs PR:PO].Description PIVOT Format([Date Needed],'Medium Date');"

    Set qdf = CurrentDb.CreateQueryDef("testy", sqlstr)
    DoCmd.OpenQuery "testy"
    Exit Sub

    errx:
    MsgBox Err.Number & " " & Err.Description

    End Sub

  3. #3
    jones is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    17
    Thank you very much Aytee111, i'll try to execute this one. you are a big help for me.

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

Similar Threads

  1. crosstab query criteria
    By Sharron in forum Queries
    Replies: 3
    Last Post: 12-15-2011, 04:31 AM
  2. crosstab query (criteria does not work)
    By Rich P in forum Access
    Replies: 1
    Last Post: 02-15-2011, 11:40 AM
  3. crosstab query (criteria)
    By Rich P in forum Queries
    Replies: 1
    Last Post: 02-14-2011, 08:40 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Criteria in Crosstab Query
    By wasim_sono in forum Queries
    Replies: 1
    Last Post: 12-12-2006, 05:14 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