Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Controls From Recordset 1

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
US
Imagine this, a form with 5 labels, spaced out (Label1, Label2, etc).

A recordset with 5 label numbers and names (1, "Green"; 2, "Purple").

How do I populate the labels in the form with the associated information from the table?

Label1 = "Green"
Label2 = "Purple"

Thanks. Sean.
 
How are ya perrymans . . .

The layout of the (fields) would help!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
perrymans . . .

As a first guess I'm considering two fields:
Code:
[blue]   Dim db As DAO.Database, rst As DAO.Recordset
   
   Set db = CurrentDb
   Set rst = db.OpenRecordset("[purple][b][i]Table/Query Name[/i][/b][/purple]", dbOpenDynaset)
   
   Do
      Me("Label" & CStr(rst!Field1)).Caption = rst!Field2
      rst.MoveNext
   Loop Until rst.Fields
   
   Set rst = Nothing
   Set db = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
I was close, but I was using an intCount rather than the recordset.

Your way soved my next problem anyway!

Now it works like a dream.

It actually wasn't "tables", but Racks, IT Racks.

My database can now dynamically create elevation views of any rack in our datacenter based on the locations entered into the database record.

No more Visio!

Thanks. Sean.
 
perrymans . . .

BTW:
Code:
[blue]   Loop Until rst.Fields
Should be:
   Loop Until rst.[purple][b]EOF[/b][/purple][/blue]
But you've apparently corrected it! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top