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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup and Nz() function

Status
Not open for further replies.

justagrunt

Technical User
Oct 10, 2002
132
Hi,
The following is an after update coding.
How can I allow a zero length string to be passed?
The Nz allows this but where would I insert it?
What happens prior to this update is the combo has a not in list where a code can be added but the description field next door will be blank. The routine gives an error message of Description can't be found etc, which why I would like to use the Nz if possible
Any Ideas appreciated.
Kind Regards

Private Sub Combo0_AfterUpdate()

Dim strFilter As String
'Evaluate filter before it is passed to Dlookup function
strFilter = "[ID]= " & [Combo0].Column(0)
'Update description controls based on value selected in stockcode combo box
Forms!OrderNumbers![Order Details]![Description] = DLookup("[DESCRIPTION]", "[InventoryCodes]", strFilter)

Exit Sub

End Sub
 
There are a couple of places you could place Nz in the code you supplied:

strFilter = "[ID]= " & nz([Combo0].Column(0), "")

'Update description controls based on value selected in stockcode combo box
Forms!OrderNumbers![Order Details]![Description] = nz(DLookup("[DESCRIPTION]", "[InventoryCodes]", strFilter), "")


which ones you use depend on your plans, e.g. you may not want to set the description at all if the combo is null.
 
Thanks very much appreciated.
Kind Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top