assign value error

bunji

Registered User.
Local time
Today, 17:15
Joined
Apr 26, 2005
Messages
124
I have an unbound text box ReleaseDescrip on a report. I want to fill it with text from a dlookup

Code:
Me.ReleaseDescrip = DLookup("[Release_Description]", "tblReleases", "[Release_type] = reports![RptEng1]![No1_Release] AND [Base] = Reports![RptEng1]![Base]")

However i get the following error message:

You Cant assign a value to this object.
 
Try
Code:
Me.ReleaseDescrip = DLookup("[Release_Description]", "tblReleases", "[Release_type] = " & reports![RptEng1]![No1_Release] & " AND [Base] = " & Reports![RptEng1]![Base])
Assuming that [No1_Release] and [Base] are both numbers
 
You don't need vba here, just set the control source of the textbox to your DLookUp statement
 
Hi Richary the Release type and base are text values. Rich i dont know how to wriet his as an expression in the control source??
 
Actually Rich has a point. If you're just placing the result of the lookup into the control ReleaseDescrip, there's no need for VB

Since Release_Type and Base are both text values you should use

Me.ReleaseDescrip = DLookup("[Release_Description]", "tblReleases", "[Release_type] = '" & reports![RptEng1]![No1_Release] & "' AND [Base] = '" & Reports![RptEng1]![Base] &"'")

that is add single quotes around Release_Type and Base.

To put this directly into your report, just use the Dlookup(..) function as the control source (not forgetting to place a '=' before the Dlookup(..))
 

Users who are viewing this thread

Back
Top Bottom