From table into label.caption ?

S

SpookiePower

I want to run a sql (select xxx from tabel1 where xxx = xxx)
and want to put the result of that sql into the caption of a label.
But when I put the sql in the property caption in the label, it
ofcourse write the sql on the form. But how do I then get
the result to show up in the caption ?
 
W

Wayne Morgan

1) Use a textbox instead of a label. You can format the textbox to make it
look like a label, if desired. You would then use the Control Source of the
textbox to put in your equation. The SQL won't be recognized, you'll need to
use an Aggregate Function, such as DLookup(), instead. This would make the
textbox a "calculated control".

2) Use the DLookup() function as mentioned above in the form's or report's
VBA module. You would add code that would take the result of the DLookup()
and assign it to the label's Caption property.
 
S

SpookiePower

Wayne Morgan said:
1) Use a textbox instead of a label. You can format the textbox to make it look like a label, if desired. You would then use the
Control Source of the textbox to put in your equation. The SQL won't be recognized, you'll need to use an Aggregate Function, such
as DLookup(), instead. This would make the textbox a "calculated control".

2) Use the DLookup() function as mentioned above in the form's or report's VBA module. You would add code that would take the
result of the DLookup() and assign it to the label's Caption property.

Thanks alot. I got it to work with the Dlookup.
 

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