Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookfuntion not doing anything.. 1

Status
Not open for further replies.

wshm

Programmer
Dec 7, 2006
62
US
Below coding is suppose to get value "FYMO" where "txtBtxDate" is between Bdate and Edate.
I set this in afterevent property of txtBtxDate but it's not doing anything.. is something wrong?

Private Sub txtBtxDate_AfterUpdate()

txtFYMO = DLookup("[FYMO]", "tbl_FYMO", "[Bdate] < #" & _
txtBtxDate & "# AND [Edate] = #" & txtBtxDate & "#")

Me.txtFYMO.Requery

End Sub

 
try this first!

Code:
Private Sub txtBtxDate_AfterUpdate()
Dim rslt

  rslt = DLookup("[FYMO]", "tbl_FYMO", "[Bdate] < #" & _
            txtBtxDate & "# AND [Edate] = #" & txtBtxDate & "#")
      
    Msgbox rslt
 
    Me.txtFYMO = rslt

End Sub

is msgbox coming up with a value?

If so then your field txtFYMO should be populated with the new value.
 
i'm getting an error msg "Run-Time error '94', Invalid use of Null.

and

msgbox rslt is highlighted..
 
I Think this will work.

Code:
Private Sub txtBtxDate_AfterUpdate()
Dim rslt

  rslt = DLookup("[FYMO]", "tbl_FYMO", "[Bdate] < #" & _
            me.txtBtxDate & "# AND [Edate] = #" & me.txtBtxDate & "#")
      
    Msgbox NZ(rslt, "Empty")
 
    Me.txtFYMO = rslt

End Sub

If you get the message "Empty", that means that there is no record matching the criteria of the DLookup.
 
thank you for your fast response zevw. for some reason, im getting the msg (empty) but no event is occuring. txtFYMO is still null..
 
just saw the last part of your message. that's very strange because there's a match criteria...
 
sigh... what am i thinking..


rslt = DLookup("[FYMO]", "tbl_FYMO", "[Bdate] < #" & _
me.txtBtxDate & "# AND [Edate] > #" & me.txtBtxDate & "#")

i changed the = to > and it's working now. Thx and happy holidays!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top