query & form help please !

  • Thread starter Thread starter Nikko
  • Start date Start date
N

Nikko

hello ,

Is it possible to enter a query as a source for a textlabel or textbox ?

for exemple : select firm_name from FIRM where id in (select id_firm
from EMPLOYEE where id=XXX)

thank you
 
YES - I do that with Unbound Forms, w/ of course Unbound
Controls.

With the recordset you generate, you can put those values
into the unbound textboxes.

HTH - Bob
 
Despite what Bob said, it's not possible. You cannot use a SQL statement as
the control source for a control.

For a textbox, you could use:

=DLookup("firm_name", "FIRM", "id = " & DLookup("id_firm", "EMPLOYEE",
"id='XXX'"))

(including the equal sign), but that is a hard-coded XXX: if you wanted to
be able to vary what XXX was, you'd be out of luck.

For the caption of a label, your only option would be to set it in VBA code:

Me.MyLabel.Caption = DLookup("firm_name", "FIRM", "id = " &
DLookup("id_firm", "EMPLOYEE", "id='XXX'"))

Here, since you're using VBA, you'd be able to change XXX:

strCurrID As String

strCurrID = "XXX"
Me.MyLabel.Caption = DLookup("firm_name", "FIRM", "id = " &
DLookup("id_firm", "EMPLOYEE", "id='" & strcurrID & "'"))
 
Doug - Perhaps there's a miscommunication.

Using an Unbound Form, and Unbound Controls...I use A Query, or SQL
Statement, to get a Recordset. Then With that recordset, it's very easy to
populate the textboxes. I've been doing it for years. One of my Clients is
a major Automaker. They request my Forms to be built that way.

Bob
 
Back
Top