Results 1 to 4 of 4
  1. #1
    Calteq is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2019
    Posts
    11

    open a report using 'where' and 'and'

    I am trying to open a report using the 'where' criteria with an 'and' condition




    strWhere = "[leagueno] = " & Me![leagueno] & " And [Team] = " & Me![Team]

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.OpenReport "rptFixtureList", acPreview, , strWhere

    this throws up a dialog asking for the exact parameter in the 'and' condition

    any help will be appreciated

    thx
    Geoff
    Attached Thumbnails Attached Thumbnails paramError.JPG  

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    as you have constructed it, the expectation is that leagueno and team are numeric

    it looks like team should be text in which case surround with single quotes - try

    strWhere = "[leagueno] = " & Me![leagueno] & " And [Team] = '" & Me![Team] & "'"

    Also better to use Me. rather than Me!. Two reasons - using Me. enables intellisense and does what is called early binding. Me! does not enable intellisense and late binds. With early binding, most errors will be identified when you compile the code, with late biding they will not be identified until the code is running - which makes it harder to debug.

    Also ensure each module has Option Explicit at the top just below Option Compare Database - this will also help to identify errors on compilation

  3. #3
    Calteq is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Oct 2019
    Posts
    11
    Marvellous

    Thx very much works!
    However had to add a single quote hilighted bold

    strWhere = "[leagueno] = " & Me.[leagueno] & " And [Team] =" & "'" & Me.[Team] & "'"

    forgot about numeric and text fields

    Geoff

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    You don't need that ampersand

    " And [Team] =" & "'"

    is the same as

    " And [Team] =
    '"

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

Similar Threads

  1. Replies: 5
    Last Post: 02-28-2017, 02:45 PM
  2. Replies: 2
    Last Post: 03-13-2016, 02:01 PM
  3. Replies: 4
    Last Post: 12-09-2015, 09:02 AM
  4. Replies: 3
    Last Post: 07-22-2014, 11:37 AM
  5. Help on report to open form to open query...
    By saseymour in forum Programming
    Replies: 13
    Last Post: 07-16-2013, 08:11 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