If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Retrieving a Record from a Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-03, 14:43
bobbyg9 bobbyg9 is offline
Registered User
 
Join Date: May 2003
Posts: 1
Retrieving a Record from a Query

I have managed to open a Query through a Macro in Access, and i can traverse the records too, via the

DoCmd.GoToRecord acDataQuery, "Query Name"

command.

However, I was wondering if there is a way I could actually get the current record information in a String, so that I can write this string to a file.

i.e. My high level pseudo code is:

while(No more records)
curRecord = getCurrentRecord; // HOW DO I DO THIS ?
write CurRecord to a textfile;
goto nextRecors.
end

Any insight will be highly appreciated !

Thanks,
bobby
Reply With Quote
  #2 (permalink)  
Old 06-03-03, 17:15
Ad Dieleman Ad Dieleman is offline
Registered User
 
Join Date: Jan 2003
Location: Dordrecht, The Netherlands
Posts: 95
Re: Retrieving a Record from a Query

You can do this by using a recordset, like this:

Sub GetStrings()
Dim DB As DAO.Database, RS As DAO.Recordset

Set DB = CurrentDb
Set RS = DB.OpenRecordset("Query Name")

Do Until RS.EOF
'FieldName stands for the field name in the query that you want
'to retrieve; in this case it is simply shown in the output window
Debug.Print RS.Fields("FieldName")
RS.MoveNext
Loop

Set RS = Nothing
Set DB = Nothing

End Sub

Quote:
Originally posted by bobbyg9
I have managed to open a Query through a Macro in Access, and i can traverse the records too, via the

DoCmd.GoToRecord acDataQuery, "Query Name"

command.

However, I was wondering if there is a way I could actually get the current record information in a String, so that I can write this string to a file.

i.e. My high level pseudo code is:

while(No more records)
curRecord = getCurrentRecord; // HOW DO I DO THIS ?
write CurRecord to a textfile;
goto nextRecors.
end

Any insight will be highly appreciated !

Thanks,
bobby
Reply With Quote
  #3 (permalink)  
Old 06-04-03, 11:30
DerFarm DerFarm is offline
Registered User
 
Join Date: Nov 2002
Posts: 19
you can use GetString.

http://www.devguru.com/Technologies/...getstring.html

has a good overview of what it does.

Essentially, stringvar=RST.Getstring(arguments) will return a string with the column and row delimiters whatever you wish. You can then work on this string with the normal string utilities.


Good Luck
__________________
DerFarm
It IS as bad as you think
and they ARE out to get you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On