View Full Version : assign value error


bunji
10-27-2005, 02:14 AM
I have an unbound text box ReleaseDescrip on a report. I want to fill it with text from a dlookup

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.

richary
10-27-2005, 03:36 AM
Try

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

Rich
10-27-2005, 03:40 AM
You don't need vba here, just set the control source of the textbox to your DLookUp statement

bunji
10-28-2005, 03:02 AM
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??

richary
10-28-2005, 09:01 AM
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(..))