Results 1 to 9 of 9
  1. #1
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Using the asterisk to select all revisited


    I am using this to fill a text box with a delimited string.

    Code:
    Private Sub BidStatus_Click()
    
        Dim Items   As Variant
        Dim Item    As Variant
        ' NB: Make this a Private variable of the code module.
        Dim filter1 As String
           If Me.BidStatus.Column(0) = "*" Then
    
    
    Dim j
    
    
    With Me.BidStatus
        For j = 0 To .ListCount - 0
             .Selected(j) = True
        Next
    End With
    
    
    End If
    
    
     
    End Sub
    It results in the following: IN ('*','Budget/Engineer','Design Build','Lost','Not Tracking','Omit','Open/Quote','Option','Plan & Spec.','REBID','Won')

    I don't want the asterisk included in that statement. I've tried replacing (using Replace) it with nothing, to no avail (Error "Argument not optional").
    Code:
      Dim str As String
    
        str = Me.filter1
    
    
        Replace InStr(1, str, "*", vbTextCompare)
    Any other ideas that I can try? Thank you for your time!

  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,642
    I'm curious if it actually hurts anything, but you could start your loop at 1 instead of 0 if it's the first item.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,275
    I do not think your Replace function is correct?

    Code:
    tt="IN ('*','Budget/Engineer','Design Build','Lost','Not Tracking','Omit','Open/Quote','Option','Plan & Spec.','REBID','Won')"
    tt1 = replace(tt,"'*',","")
    ? tt1
    IN ('Budget/Engineer','Design Build','Lost','Not Tracking','Omit','Open/Quote','Option','Plan & Spec.','REBID','Won')
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    in vb, 0 is the 1st item of lists.

  5. #5
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    And BOOM! We have a winner! Thanks again Paul! You're a rockstar!!

  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,642
    Quote Originally Posted by Gina Maylone View Post
    And BOOM! We have a winner! Thanks again Paul! You're a rockstar!!
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Paul,
    Should this
    Code:
    IN ('Budget/Engineer','Design Build','Lost','Not Tracking')
    work as query criteria? When I copy and paste the actual output text, it works as it should, but when I reference the form field, I get nothing.

    Code:
    SELECT DISTINCTROW ProjectItems.ItemBid, MFGs.MFG, Projects.BidDate, Projects.ProjectName, BidStatus.BidStatusFROM MFGs INNER JOIN (BidStatus INNER JOIN (Projects INNER JOIN ProjectItems ON Projects.ProjectID = ProjectItems.ProjectID) ON BidStatus.BidStatusID = ProjectItems.BidStatusID) ON MFGs.MFGID = ProjectItems.MFGID
    GROUP BY ProjectItems.ItemBid, MFGs.MFG, Projects.BidDate, Projects.ProjectName, BidStatus.BidStatus, ProjectItems.MFGID
    HAVING (((MFGs.MFG)=[Forms]![CompareSales]![filter2]) AND ((Projects.BidDate) Between [Forms]![CompareSales]![firstbegindate_beginr] And [Forms]![CompareSales]![firstbegindate_endr]) AND ((BidStatus.BidStatus)=[Forms]![CompareSales]![filter1]));
    TIA!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    It works as a criteria but not from a form reference (to the best of my knowledge). In essence you're saying "WHERE FieldName = In(...)" which is invalid SQL with both = and In().

    If you're opening a form or report, I'd use it as a wherecondition.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Thank you Welshgasman! It's perfect! Happy holidays to you!

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

Similar Threads

  1. List box select all when clicking on asterisk
    By Gina Maylone in forum Access
    Replies: 4
    Last Post: 12-14-2020, 12:20 PM
  2. Find and delete asterisk from name field
    By pgruenke in forum Reports
    Replies: 6
    Last Post: 03-26-2018, 03:20 PM
  3. Replies: 1
    Last Post: 10-28-2011, 01:57 PM
  4. Delete and Update VBA - Revisited
    By shexe in forum Programming
    Replies: 1
    Last Post: 08-26-2010, 10:34 AM
  5. Sending parameters to queries - Revisited
    By Merkava in forum Programming
    Replies: 3
    Last Post: 12-08-2009, 01:05 PM

Tags for this Thread

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