setting controlsource

B

Brian

Hello all.

This is what I want to do in vba code on form load.

Me.txtBanner.ControlSource = DLookup
("Version", "Version", "[Stop] = Yes")

The problem is that I need an equals sign before dlookup
or I get #Name in the text box.

can't put the dlookup error in quotes like this
"=DLookup("Version", "Version", "[Stop] = Yes")"

I get a compile error...end of statement.

any suggestions on how I do this?
 
A

Allen Browne

In your expression:
"=DLookup("Version", "Version", "[Stop] = Yes")"
Access thinks it has come to the end of the quote just before Version, and
doesn't know what to do with the rest of the line. Where you have quotes in
quotes, you must double them up, e.g.:
"This string has a ""word"" in quotes"

Try:
Me.txtBanner.ControlSource = "=DLookup(""Version"", ""Version"", ""[Stop] =
True"")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top