Dlookup problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mmorgan1240@sbcglobal.net

    Dlookup problem

    I have a form that I am trying to update. I would like to have a field
    populated by another table (State_laws) based on the value of another
    field on the form.
    I have a field called "state". When the user inputs a state I would
    like another field to be populated based on the lookup of another table
    based on the state. I am getting the value &name in my new unbound text
    box. Here is my dlookup statement please help me figure out what I am
    doing wrong.
    =dlookup("State law","state_law s","State=" & state)Do I need a trigger
    associated with the new field or the state field to kick off this
    lookup?
    Thank you for any help.

  • salad

    #2
    Re: Dlookup problem

    mmorgan1240@sbc global.net wrote:[color=blue]
    > I have a form that I am trying to update. I would like to have a field
    > populated by another table (State_laws) based on the value of another
    > field on the form.
    > I have a field called "state". When the user inputs a state I would
    > like another field to be populated based on the lookup of another table
    > based on the state. I am getting the value &name in my new unbound text
    > box. Here is my dlookup statement please help me figure out what I am
    > doing wrong.
    > =dlookup("State law","state_law s","State=" & state)Do I need a trigger
    > associated with the new field or the state field to kick off this
    > lookup?
    > Thank you for any help.
    >[/color]
    Remember...stri ngs surrounded by quotes, dates by #, numbers by nothing

    intNum = 1
    dat = Date()
    sn = "MN"
    ? "state = """ & SN & ""
    state = "MN
    ? "state = '" & sn & "'"
    ? "datefld = #" & dat & "#"
    ? "Numfield = " & intnum

    Comment

    • mmorgan1240@sbcglobal.net

      #3
      Re: Dlookup problem

      Salad, thanks for your reply. Do I need some kind of event trigger to
      get this to happen? Or will the dlookup happen as soon as the state
      field is populated?
      Thanks again.

      Comment

      • salad

        #4
        Re: Dlookup problem

        mmorgan1240@sbc global.net wrote:
        [color=blue]
        > Salad, thanks for your reply. Do I need some kind of event trigger to
        > get this to happen? Or will the dlookup happen as soon as the state
        > field is populated?
        > Thanks again.
        >[/color]
        I'll assume that is your control source for the field. So, yes it
        should update correctly. If it doesn't, a simple fix is to requery the
        field. Let's say the Text field is called Text1 with the dlookup and
        the input field is called Input1. In the Input1 AfterUpdate you can enter
        Me.Text1.Requer y

        Comment

        Working...