Results 1 to 5 of 5

Thread: vba search $ sign ($2000 - $3000)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    vba search $ sign ($2000 - $3000)

    Hello there,

    i've a set of code to search through table containing column values like $2000 - $3000, $5000 - $6000 and so on.

    If i were to enter something like $2000 - $5500, both results would be displayed.

    unfortunately, the set of code works only when the values are without the $ sign.

    Similarly, i have other values for [Age Group] which has values like 30 - 50 and etc. (without the $ sign) and... it works perfectly.

    How can i alter the codes to accomodate the $ sign?

    VB Code:
    1. sMHouse = Me.TextMHouse
    2. sMH = Split(sMHouse, " ")
    3.  
    4. sMHouse = "  and ( "
    5.        
    6.         Do While sMH(0) <= sMH(1)
    7.            
    8.             sMHouse = sMHouse & " ( [Monthly Household] like '%" & sMH(0) & "%' ) or "
    9.             sMH(0) = sMH(0) + 1
    10.         Loop
    11.        
    12.          sMHouse = Mid(sMHouse, 1, Len(sMHouse) - 5)
    13.          
    14.          sMHouse = sMHouse & " or [Monthly Household] not like '%" & sMH(0) & "%' or [Monthly Household] not like '%" & sMH(1) + 1 & "%') and [Monthly Household] is not null ) "


    Thank You

    Astro

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: vba search $ sign ($2000 - $3000)

    Is this a numeric field in Access?

    If so, the data does not contain the $ sign (that is purely for display purposes), so a search containing it will not work - and you should remove the $ sign from your search criteria.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: vba search $ sign ($2000 - $3000)

    Hey si_the_geek

    It is in text format because the application user ocasionally enters some text, her database is very inconsistent.

    ive tried doing a replace but still doesn't work.


    VB Code:
    1. sMHouse = Me.TextMHouse
    2.  
    3. sMH = Split(sMHouse, " ")
    4.  
    5. sMHouse = "  and ( "
    6.        
    7.         Do While sMH(0) <= sMH(1)
    8.            
    9.             sMHouse = sMHouse & " ( Replace([Monthly Household],'$','') like '%" & sMH(0) & "%' ) or "
    10.             sMH(0) = sMH(0) + 1
    11.         Loop
    12.        
    13.          sMHouse = Mid(sMHouse, 1, Len(sMHouse) - 5)
    14.          
    15.          sMHouse = sMHouse & " or Replace([Monthly Household],'$','') not like '%" & sMH(0) & "%' or Replace([Monthly Household],'$','') not like '%" & sMH(1) + 1 & "%') and [Monthly Household] is not null ) "
    16. MsgBox sMHouse

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: vba search $ sign ($2000 - $3000)

    I don't understand why you cant search for text including $, I've never had a problem with it before.

    You put the Replace in completely the wrong place, you want to update in the Input (ie: sMH(0) and sMH(1)) rather than the fields.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: vba search $ sign ($2000 - $3000)

    Hey si_the_geek

    sorry for the late reply. ill give it a shot again. thanks for the suggestion.

    =)

    Astro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width