Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

How to tell if string is missing?

Discussion in 'Information Technology' started by AbraAbraCadabra, Jul 28, 2006.

  1. AbraAbraCadabra

    AbraAbraCadabra
    Expand Collapse
    Guest

    How can I tell if a string is non-existent? If found this code on the
    web, but it doesn't seem to be working for me...What am I doing wrong?

    If Not IsMissing(strData) Then
    MsgBox "the variable exists"
    End If
     
  2. Loading...

    Similar Threads Forum Date
    Should One Always Tell The Truth? Sikh Sikhi Sikhism Sep 20, 2016
    Sikh News 'Saakhi' Audio App To Tell Stories Of Sikh History, Valour - Hindustan Times Breaking News Jul 29, 2016
    Hukkam And Fortune Telling Questions and Answers Apr 24, 2016
    Hard Talk Taking One Liners Out Of Context From Gurbani To Allow Intellectual Independence? Hard Talk Apr 23, 2016
    Sikh News Greg Worthington: Let Me Tell You Why This Hateful Joke Isn't Funny Breaking News Feb 18, 2016

  3. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    How is strData declared? If it's as a string, the only possibility is a
    zero-length string (""), so you'd use

    If Len(strData) > 0 Then

    If it's declared as a variant, it could also be Null. The simplest check
    would then be:

    If Len(strData & "") > 0 Then

    On the odd chance that the string might contain a number of blanks, you
    could use the following instead:

    If Len(Trim(strData)) > 0 Then

    or

    If Len(Trim(strData & "")) > 0 Then

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "AbraAbraCadabra" <nws@gsw-inc.com> wrote in message
    news:O2RoO02cGHA.380@TK2MSFTNGP04.phx.gbl...
    > How can I tell if a string is non-existent? If found this code on the
    > web, but it doesn't seem to be working for me...What am I doing wrong?
    >
    > If Not IsMissing(strData) Then
    > MsgBox "the variable exists"
    > End If
    >
    >
     
  4. bmoore.personal@gmail.com

    bmoore.personal@gmail.com
    Expand Collapse
    Guest

    Found this

    "Only Variants can contain the value Missing. If you assign any other
    type to an optional parameter it will be initialized with a value (0
    for numbers, "" for strings, etc). When you test if the optional
    argument is Missing, Access sees it has a value. As a result,
    IsMissing() returns False, even if the parameter was not supplied by
    the user."
     
  5. Ron2006

    Ron2006
    Expand Collapse
    Guest

    1) Are you trying to see if a set of characters is somewhere in a
    larger string

    Or

    2) trying to see if the field(string) is empty?

    1) if instr(me.largerfieldname,"findme") >0 then
    msgbox "the variable exists"
    endif


    2) if not isnull(me.fieldname) then
    msgbox "The varialble exists"
    endif
     
  6. Ron2006

    Ron2006
    Expand Collapse
    Guest

    or

    2) if len(me.fieldname) > 0 then
     
  7. chriske911

    chriske911
    Expand Collapse
    Guest

    AbraAbraCadabra was thinking very hard :
    > How can I tell if a string is non-existent? If found this code on the
    > web, but it doesn't seem to be working for me...What am I doing wrong?


    > If Not IsMissing(strData) Then
    > MsgBox "the variable exists"
    > End If


    if not string <> "" then beep

    grtz
     
  8. AbraAbraCadabra

    AbraAbraCadabra
    Expand Collapse
    Guest

    <bmoore.personal@gmail.com> wrote in message
    news:1147182364.766330.263860@j73g2000cwa.googlegroups.com...
    > Found this
    >
    > "Only Variants can contain the value Missing. If you assign any other
    > type to an optional parameter it will be initialized with a value (0
    > for numbers, "" for strings, etc). When you test if the optional
    > argument is Missing, Access sees it has a value. As a result,
    > IsMissing() returns False, even if the parameter was not supplied by
    > the user."
    >


    Excellent answer, bmoore, thanks alot this fixed my problem!
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page