Results 1 to 11 of 11

Thread: Like

  1. #1
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Unanswered: Like

    I have a field its value could be BAT1, BAT1a, BAT2, BAT2b, BAT2c, BAT3, BAT4a, BAT4b,....

    I want to do something if it is BAT1 or BATa1
    Also
    I want to do something else if after BAT another number comes but not the 1

    How can I use LIKE with IF to make such comparison

    I used

    If rs("BvlGr_Romisch") Like "BAT1?" Then ' [BAT1a] and [BAT1b]
    &nbsp;&nbsp;If rs("alter") < 30 Then
    &nbsp;&nbsp; UrlaubDays = 26
    &nbsp;&nbsp; ElseIf rs("alter") >= 30 Then
    &nbsp;&nbsp; UrlaubDays = 30
    End If
    ElseIf ("BvlGr_Romisch") Like "BAT*" Then '
    endif

    I can not use the Astrics here, because if I use it, it includes the BAT1 and BAT1a which I don't need here.

    Thanks

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Exclamation

    If I do this then I could select all BAT from BAT2 to BAT10, I mean BAT8b would be true and BAT1bs would be False?

    If ("BvlGr_Romisch") Like "BAT[2-10]*" Then

    endif

  3. #3
    Join Date
    Oct 2003
    Posts
    66

    Re: Like


    If rs("BvlGr_Romisch") Like "BAT1?" Then ' [BAT1a] and [BAT1b]
    &nbsp;&nbsp;If rs("alter") < 30 Then
    &nbsp;&nbsp; UrlaubDays = 26
    &nbsp;&nbsp; ElseIf rs("alter") >= 30 Then
    &nbsp;&nbsp; UrlaubDays = 30
    End If
    ElseIf ("BvlGr_Romisch") Like "BAT*" Then '
    endif
    how about try this,

    For you second to last line that is :
    elseif ("BvlGr_Romisch") Like "BAT*" Then

    Change to:
    elseif ("BvlGr_Romisch") Like "BAT*" And ("BvlGr_Romisch") Not Like "BAT1?" Then

    I haven't testsed it at all but might be what your looking for.
    Good luck

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Thank you for replying, I tried your suggestion

    If rs("BvlGr_Romisch") Like "BAT*" And rs("BvlGr_Romisch") not Like "BAT1?" then

    endif

    but it gives a syntax error with the secound like


    I tried also

    If rs("BvlGr_Romisch") Like "BAT[1-1][a-a]" Then


    but in vain

    Thanks

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Like

    Originally posted by adrkoehler
    how about try this,

    For you second to last line that is :
    elseif ("BvlGr_Romisch") Like "BAT*" Then

    Change to:
    elseif ("BvlGr_Romisch") Like "BAT*" And ("BvlGr_Romisch") Not Like "BAT1?" Then

    I haven't testsed it at all but might be what your looking for.
    Good luck
    I tried
    If rs("BvlGr_Romisch") Like "BAT*" And rs("BvlGr_Romisch") Like Not "BAT1?" Then

    but it gives Type mismatch

  6. #6
    Join Date
    Oct 2003
    Posts
    66
    Okay sorry I don't use like statement much. Try this instead

    elseif ("BvlGr_Romisch") like "BAT*" and ("BvlGr_Romisch") like "BAT1?" = false then

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by adrkoehler
    Okay sorry I don't use like statement much. Try this instead

    elseif ("BvlGr_Romisch") like "BAT*" and ("BvlGr_Romisch") like "BAT1?" = false then

    It takes only BAT1

    but BAT1a not

  8. #8
    Join Date
    Oct 2003
    Posts
    66
    Okay try useing a * instead ? for second like

    elseif ("BvlGr_Romisch") like "BAT*" and ("BvlGr_Romisch") like "BAT1*" = false then

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by adrkoehler
    Okay try useing a * instead ? for second like

    elseif ("BvlGr_Romisch") like "BAT*" and ("BvlGr_Romisch") like "BAT1*" = false then
    No It doesn't function

    Thank you for your time, I'll try something else than that like.

    Thanks again

  10. #10
    Join Date
    Oct 2003
    Posts
    66
    Sorry...tried my best.

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by adrkoehler
    Sorry...tried my best.
    Don't worry, it was nice to participate and change knowledge.

Posting Permissions

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