Limit to List question?

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

    #1

    Limit to List question?

    I have a form: frmVehicleEntry Form
    The form has a combo-box control: AuthEntityChoos erBox
    The combo-box has a RowSource: property of:
    SELECT DISTINCTROW IIf(IsNull([Company]),[Name],[Company]) AS
    EntityName, qryAuthorizingE ntities.Address ,
    IIf(IsNull([Company]),"Person","Com pany") AS EntityType,
    qryAuthorizingE ntities.AuthID FROM qryAuthorizingE ntities;
    The combo-box's BOUND field is the 4th and last field: AuthID

    qryAuthorizingE ntities lists values between 1 and 350 in the AuthID
    field. There are NO RECORDS in the source table (tblAuth) with values
    over 350 - none.

    The combo-box's LimitToList property is set to Yes.

    How is it, then, that the following line runs WITHOUT ERROR
    and actually succeeds in placing 500 in that control?
    Me!AuthEntityCh ooserBox = 500

    I can type Print Me!AuthEntityCh ooserBoxin the debug window and it
    will return 500. The value is DEFINITELY there. How can that be?
  • Albert D. Kallal

    #2
    Re: Limit to List question?

    I not tested this, but in code, you can do all kinds of things, and the user
    interface is ignored.

    When you modify a value via code, NONE of the events fire. So, the before
    update, after update, not in list....all of those things don't fire (none
    never did..for the last 15+ years of ms-access).

    So, it not really much of a surprise that the not-in list code don't
    fire...since events don't fire when you use code and by-pass the user
    interface.

    The above is not only an explain, but, if you realize that events don't fire
    when modifying values via code..then the ability to by-pass what you have on
    a form makes sense. often, this ability is EXACLTY why we use code!!

    If you going to need to limit the list via code, then you have to test.

    eg:

    dim lngValue as long


    lngValue = 500

    if isnull(dlookup( "AuthID","qryAu thorizingEntiti es","Authid = " & lngValue))
    = true then
    ....value is not legal..
    else
    .....value is ok
    end i


    --
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada
    pleaseNOOSpamKa llal@msn.com


    Comment

    • MLH

      #3
      Re: Limit to List question?

      Thanks, Albert.
      I understand.

      Comment

      Working...