Results 1 to 6 of 6
  1. #1
    fountain27 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2019
    Posts
    25

    Combo Box - DoCmd syntax question

    I am struggling with the proper syntax passing 2 inputs from a combo box to a report. I sincerely appreciate any suggestions.



    Code:
    DoCmd.OpenReport "qry_Monthly_Production_Log", acViewReport, , "IssueYear=" & Me.txtYear & " " & "Months=" & Me.Month
    [IMG][/IMG]

  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,518
    You need to separate the 2 conditions with AND, plus the fields where the data type is text need to have delimiters, like

    ...Month = '" & Me.Month & "'"

    More here on delimiters:

    http://www.baldyweb.com/BuildSQL.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    fountain27 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2019
    Posts
    25
    Sorry, I must be stuck on slow today. I thought I understood the info on Paul's website, but now I am getting a Type Mismatch Error. Thanks again for help.

    Code:
    DoCmd.OpenReport "qry_Monthly_Production_Log", acViewReport, , "IssueYear=" & Me.txtYear And "Month = '" & Me.Month & "'"

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try

    DoCmd.OpenReport "qry_Monthly_Production_Log", acViewReport, , "IssueYear=" & Me.txtYear & " And Month = '" & Me.Month & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    fountain27 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2019
    Posts
    25
    Thank you so much!!!!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. DoCmd.SendObject acSendNoObject - Syntax error
    By moneypennie21 in forum Programming
    Replies: 3
    Last Post: 05-24-2017, 05:40 AM
  2. Correct Syntax For DoCmd
    By bidbud68 in forum Programming
    Replies: 3
    Last Post: 10-18-2012, 03:12 PM
  3. Syntax Error with DoCmd.RunSQL
    By dandoescode in forum Programming
    Replies: 2
    Last Post: 06-25-2012, 11:06 AM
  4. DoCmd.OpenForm Syntax Error
    By alsoto in forum Forms
    Replies: 3
    Last Post: 02-29-2012, 01:14 PM
  5. Replies: 2
    Last Post: 10-13-2011, 09: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