Send record "name" fields to label or textbox question

hardrock

Registered User.
Local time
Today, 03:00
Joined
Apr 5, 2007
Messages
166
Gooday all, i have a table that consist of 3 columns, name, address and telephone number.

The table consists of about 20 records. What i would like to do is simply show one by one all the names from my table sequentially upon clicking a button on my form. I dont mind if its shown within a label or text box on my form. I would see something like

"Processing <persons name here>"

with a interval of 10 seconds between each name. Any ideas?
 
Hardrock,

You can easily set up a recordset to loop through your table.

Code:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Select * from YourTable Order by PersonsName")
While Not rst.EOF And Not rst.BOF
   '  What do we do here ???
   rst.MoveNext
   Wend

In the "What do we do here" part, you can move the name to a textbox:

Me.SomeTextBox = rst!PersonsName

Then, you can use the form's Timer Event to count off ten seconds, or make an
API call to a Sleep function.

But more importantly, what is the 10-second wait for?

Wayne
 
but you have navigation buttons at the bottom

just click the vcr controls to progress through the records, rather than having timed changes

much easier and no programming
 
Thanks Guys!

Wayne,

The 10 second is so i can see the result occuring. Thats it :)

I have a problem with the code sniplet. it says

"Too few parameters. Expected 1" I am loading the Name, address and phone from a query called "persons"

so i have

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Select * from persons Order by Name")
While Not rst.EOF And Not rst.BOF

Me.nam = rst!Name ' nam is name of textbox on form

rst.MoveNext
Wend

Any ideas??
 
HR,

Actually, it looks OK.

Name is a reserved word though ... that can cause you problems.

What happens if you paste the SQL string into a query?
Get the query in Design View and right-click and choose sql.

Wayne
 

Users who are viewing this thread

Back
Top Bottom