Results 1 to 3 of 3
  1. #1
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Open Report based on list box selection

    Hello everybody,

    I know this is a smal problem but it has buffled me for while. I would like to open report called "Miami Dade Garnishment " based on selection in list box called " Date QB" . The list box has only one row that is date in date format of dates that have been upload in Access . I looked up in forum and come up with this code but for some reason it doesn't work:

    Dim stDocName As String
    Dim Criteria As String
    Dim i As Variant

    stDocName = "Miami Dade Garnishment"

    Criteria = ""
    For Each i In Me![Date QB].ItemsSelected
    If Criteria <> "" Then
    Criteria = Criteria & " OR "
    End If
    Criteria = Criteria & "#[DateUploadQB]= #" _
    & Me!
    [List1].ItemData(i) & "'"
    Next i
    Debug.Print Criteria
    DoCmd.OpenReport stDocName, acPreview, , Criteria

    Me.Filter = Criteria


    Me.FilterOn = True


    The filed in the report that is DateUploadQB in date format as well.

    Thank you in advance for help,

    Regards,

    GomelBoris

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    check your criteria
    Code:
    Criteria = Criteria & "#[DateUploadQB]= #" _
            & Me!
    [List1].ItemData(i) & "'"
    The "#" sign is in wrong place -
    Code:
    "[DateUploadQB]=#" & Me!
    [List1].ItemData(i) & "#"
    Dates should be surrounded by "#" sign.

    I do not know about your database. Why not use a combo box or text box instead of list box?

  3. #3
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101
    Thank you Amrut. It works as magic. Really appreciate you. Thousand of thanks. Probabaly , i go with text box instead of the list box b/c list box is long.
    The best regards,
    GomelBoris

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

Similar Threads

  1. Replies: 9
    Last Post: 10-16-2012, 07:51 AM
  2. Replies: 2
    Last Post: 06-09-2012, 07:59 AM
  3. Open a report based on a filtered list box
    By irish634 in forum Access
    Replies: 5
    Last Post: 02-07-2012, 08:10 AM
  4. Update table based on List Box selection
    By tpcervelo in forum Forms
    Replies: 0
    Last Post: 11-04-2010, 01:32 PM
  5. Replies: 2
    Last Post: 08-03-2010, 10:16 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