making sure that a selection has been made in a combobox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ColinWard

    making sure that a selection has been made in a combobox


    Hi again.

    I am trying to figure out how to make sure that a value has been
    selected from a combobox on a form. I have tried using
    isnull(combobox name.text) and
    isempty(combobo xname.text)and isnull(combobox name.value) in the onexit
    event but I cannot get it to work.

    basically the combo contains a value list of possible salutations(e.g .
    Mr., mrs., etc.) and I want to be sure that the user chooses one of the
    salutations before they can do anything else.

    thank you

    Colin


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Brendan Reynolds

    #2
    Re: making sure that a selection has been made in a combobox

    IsNull(ComboBox .Value) or just IsNull(ComboBox ) (because Value is the
    default property of an Access combo box) should work in most circumstances.
    IsNull(ComboBox .Text) won't work, because the Text property returns a
    String, and a String cannot be Null. IsEmpty(ComboBo x.Text) or
    IsEmpty(ComboBo x.Value) won't work, as I understand it, because IsEmpty()
    returns true only when the argument is an uninitialised Variant *variable*,
    to the best of my knowledge, there is no way for a control property to
    return the Empty value.

    One situation in which IsNull(ComboBox ) or IsNull(ComboBox .Value) may not
    meet your needs is where the combo box contains a zero-length string. The
    following expression will return True if the control contains either Null or
    a zero-length string ...

    Len(ControlName & vbNullString) = 0

    .... and the following expression will also return True if the control
    contains nothing but spaces ...

    Len(Trim$(Contr olName & vbNullString)) = 0

    --
    Brendan Reynolds


    "ColinWard" <jetfighter3@ho tmail.com> wrote in message
    news:403e0737$0 $200$75868355@n ews.frii.net...[color=blue]
    >
    > Hi again.
    >
    > I am trying to figure out how to make sure that a value has been
    > selected from a combobox on a form. I have tried using
    > isnull(combobox name.text) and
    > isempty(combobo xname.text)and isnull(combobox name.value) in the onexit
    > event but I cannot get it to work.
    >
    > basically the combo contains a value list of possible salutations(e.g .
    > Mr., mrs., etc.) and I want to be sure that the user chooses one of the
    > salutations before they can do anything else.
    >
    > thank you
    >
    > Colin
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • DFS

      #3
      Re: making sure that a selection has been made in a combobox

      Set the Default value to something in the comboBox, then set the validation
      rule to Not Null


      "ColinWard" <jetfighter3@ho tmail.com> wrote in message
      news:403e0737$0 $200$75868355@n ews.frii.net...[color=blue]
      >
      > Hi again.
      >
      > I am trying to figure out how to make sure that a value has been
      > selected from a combobox on a form. I have tried using
      > isnull(combobox name.text) and
      > isempty(combobo xname.text)and isnull(combobox name.value) in the onexit
      > event but I cannot get it to work.
      >
      > basically the combo contains a value list of possible salutations(e.g .
      > Mr., mrs., etc.) and I want to be sure that the user chooses one of the
      > salutations before they can do anything else.
      >
      > thank you
      >
      > Colin
      >
      >
      > *** Sent via Developersdex http://www.developersdex.com ***
      > Don't just participate in USENET...get rewarded for it![/color]


      Comment

      • ColinWard

        #4
        Re: making sure that a selection has been made in a combobox

        thank you both for your replies. I did what DFS suggested and it worked
        perfectly.

        Colin


        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        Working...