Show field from table in textbox ?

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

I have made a pricelist in a table and have put some textboxe
on my form. Now I want to show the prices from the table in the textboxes.
But I can't get it to work.

What I have done is that I have set the property-ControlSource on the
textbox to =tablename![fieldname] but it shows #NAME? in the
textbox and not the price from the field.

What have I done wrong ??
 
You need to set a recordset for the form. While you can simply put the table
name there, my preference is to create a query that orders the records
correctly, and use the query as the recordset.

Once you've assigned a recordset to the form, you set the controlsource to
the name of a field in the recordset (no table name)
 
Douglas J Steele said:
You need to set a recordset for the form. While you can simply put the table
name there, my preference is to create a query that orders the records
correctly, and use the query as the recordset.

Once you've assigned a recordset to the form, you set the controlsource to
the name of a field in the recordset (no table name)

I'm not sure that I understand exactly what you mean.

...set a recordset for the form.
Is a recordset the result from a query ?


I have my form showing data from my customers and from
the field-list I can drag&drop the textboxes that I want to
show on my form. But the pricelist is another table than
my customer table and because of that I can't see the
price-textboxes in the field-list.

That's why I tryed to place some textboxes on my form
and then connect the textboxes to the fields in the price-table.
 
Douglas J Steele said:
You need to set a recordset for the form. While you can simply put the table
name there, my preference is to create a query that orders the records
correctly, and use the query as the recordset.

Once you've assigned a recordset to the form, you set the controlsource to
the name of a field in the recordset (no table name)

Hope not this is a stupid question.
If I want to make the recordset, it seems to me
that I have to use VBA code and connect to
the backend using ADO. Is that correct ?
 
SpookiePower said:
"Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> skrev i en
meddelelse news:[email protected]...
Hope not this is a stupid question.
If I want to make the recordset, it seems to me
that I have to use VBA code and connect to
the backend using ADO. Is that correct ?

No, that's not correct. No coding is required at all.

You have a few options.

One is to create a query that returns the information you want in the order
you want it and save that query. Let's say you named the query MyQuery. Now,
go into the Form and look at its properties. (Make sure you're looking at
the properties for the Form itself, not for any controls or sections on the
form) The first property on the Data tab (or the All tab, for that matter)
should be Recordset. Put MyQuery there.

Other alternatives include putting the name of the table for the Recordset,
or clicking on the ellipsis (...) to the right of the Recordset property
cell, and creating a query there (the SQL of the query will be put into the
Recordset Property once you exit from there).

Once you've done that, look at the properties for your text box control and
set the ControlSource appropriately.
 

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

Back
Top