pls help me on this..

i'm using this code to get data from record:

MyNum1 = DLookup("[Outcome]", "Remark", _
      "[IDRemark] = Form![SelectTxt]")
OutTxt.Value = MyNum1

my prob is when the data in [Outcome] is null , access having error to still get the null value from the record..
how to deal with this, do I need to put default value for [Outcome] field in case user don't wanna put data in it? or is there other way to handle?


Recommended Answers

All 3 Replies

I'm assuming Outcome is numeric but it wouldn't have to be but you would change the value for NZ to vbNullString if it is text.

MyNum1 = ]")[B]Nz([/B]DLookup("[Outcome]", "Remark", _
      "[IDRemark] = Form![SelectTxt]")[B],0)[/B]
OutTxt.Value = MyNum1

Thanks so much boblarson! It works great!! thanks a lot

btw i need to pull image attachment from the record..
can i use the same dlookup? do ineed array to store the data or is there any other way.. plus how to put the attachment in Attachment box in form?

MyNum2 = Nz(DLookup("[Attachment]", "Operation", _
      "[IDOp] = Form![SelectTxt]"), vbNullString)
Attachmentt.Value = MyNum2 <--this definitely an error
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.