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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping thru recordsets 1

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
Hey all. I'm very new to recordset but am learning. Is it possible to loop through a DAO recordset until .EOF and each time the loops executed display each record in a form say in datasheet or continues style? something like

open some form readonly
with rs
do until rs .EOF
forms!<name>!<txtbox>= .fields <fieldname>
.movenext

add new line in form
loop

I am just interested in displaying the data in an unbound form for readonly. there may only be 1 record or could be 100 records....any ideas?
 
In ac2003 you may programmatically set the RecordSet property of a Form ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I am not sure if I understand the scenario. You want to display all of the records, but you don't want the user to e able to edit the information?

If that is what you want to do you can lock the recordset or just use labels to display the data.

Richard
 
I'm using A2K. Yes I just want to let them view the data. I let the user use a wildcard search when someting doesn't match their criteria on the thoughts that maybe whomever entered the data made a typo. If that's the case this will let the user see this and correct it through other means. The users using this only have read access to search and find what they need. If it would need correcting they would have to go to someone with access to that part of the DB.

PHV....thanks again for all your help on my other issue!!!
 
There are a couple of options. You can use a regular form and the textboxes and change all of their locked properties to true and the user won't be able to edit the data. You can also whange the form property Allow Edits to false.

If you just want to loop through the records you can create a textbox that is as big as the screen and then in you loop do:

Me.TextBox1.Text = Me.TextBox1.Text + Data + Chr(13) + Chr(10)

That will add the carriage return line feed into the textbox. You can also send the text to a label as well.

Hope this helps.

Richard
 
Dim MyText as Variant

MyText = rs.GetString()

This returns a delimited string with line feeds per row.
 
cmmrfrds,
ur the BOMB!

Can't tell you how many times I've done:
strDelim = strDelim & rs.Fields(n) & ","

GetString indeed!

A star for you.

Tranman
 
Thank you for the star Tranman.

The ADO recordset also has a GetRows() to bring back an array, but this has the columns and rows inverted and is a little harder to work with.
 
I haven't had the chance to try this yet, but I will first thing in the morning after I do a little reading to understand how and where to use it. Thank you for the suggestion cmmrfrds. Sounds just like what I need. I'm sure another star will follow!
 
Sorry guys - what am I missing here ?

Surely the solution is to
Set up the form in 'Continuous mode'
Set the form's recordsource to blank

Then in the Form Load event

Code:
Dim strSQL as String
strSQL = "SELECT .. .. Whatever is used as the SQL string to create the recordset

Me.RecordSource = strSQL

Job Done.



OR

If the data is already in memory in an open recordset
( I use this method when the data is obtained from MySQL over ODBC )
then you can use
Code:
rst.Open "SELECT .. .. .. etc.
If Not rst.EOF Then
    Set Me.RecordSet = rst
End If


Note :
If you REALLY are using DAO with A2k then you'll need the convert the rst.Open to DAO speak. ( Or better still catch up and use ADO )


'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Goodmorning all. I've tried the getstring method and have been unsuccessful. LittleSmudge by use your first suggestion I can now get the correct number of rows in my continuous form, however i see the same record in every row. What am I doing wrong? Thanks for all the suggestions and help. I read that GetString was for ADO so will it work with my DAO?
 
I read that GetString was for ADO so will it work with my DAO?
No
Have you tried to play with the Recordset property of the form ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top