Question about Microsoft Office Standard for PC

1 Answer

Ms Access - OpenRecordset question

Hi, I made the following recordset: Set rst = db.OpenRecordset(str_Query, dbOpenDynaset) This recordset will get me 30 fields. I want to retrieve them and put the result in an array. For example: Dim Col_Title(1 To 30) As String Col_Title(1) = rst![F1] Col_Title(2) = rst![F2] ........................ Col_Title(30) = rst![F30] Now, my qustion is, instead of writing 30 lines to retrive the 30 values from the recordset, how can I write a FOR loop and get the values in least lines of code. For example: For iCount = 1 To 30 iCount = 1 Col_Title(1) = rst![F + iCount] Please suggest me how to code: Col_Title(1) = rst![F + iCount]

Posted by on

1 Answer

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points


    An expert that got 10 achievements.


    An expert that got 5 achievements.

    Vice President:

    An expert whose answer got voted for 100 times.

  • Master
  • 883 Answers
Re: Ms Access - OpenRecordset question

I think you just need to change it to read: Col_Title(iCount) = rst![F + iCount] from the original Col_Title(1) = rst![F + iCount]

Posted on Sep 20, 2007

Add Your Answer

0 characters

Uploading: 0%


Complete. Click "Add" to insert your video. Add


3 Points

Related Questions:

1 Answer

Repair MS Access database without having program installed

Use Recovery Toolbox for Access developed for recovering data from corrupted Microsoft Access databases. The MS Access recovery tool is capable of repairing MDB and ACCDB database files.

For more:

Oct 18, 2015 | Microsoft Office Business & Productivity...

1 Answer

How to invoke a ms.access using parser

To parse a Text field that contains two words separated by a comma, follow these steps:
  1. Open any existing database.
  2. Create a table with the following structure: Table: Parse2Words
    Field Name: Empl
    Data Type: Text
  3. View the Parse2Words table in Datasheet view and type the following three records in the Empl field: Smith, John
    Callahan, Laura
    Fuller, Andrew
  4. Create the following query based on the Parse2Words table: Query: QueryTest
    Field: FirstName: Right$([Empl],Len([Empl])- InStr(1,[Empl],",")-1)
    Show: True
    Field: LastName: Left$([Empl],InStr(1,[Empl],",")-1)
    Show: True

    NOTE: You can modify the QueryTest query to account for spaces between the two parts in the Empl field. For example, if the text in the Empl field is "Smith,John" without spaces, remove the -1 from the FirstName field expression.
  5. Run the query. Note that the QueryTest query separates the text in the Empl field into the two fields below: FirstName LastName
    John Smith
    Laura Callahan
    Andrew Fuller

Jan 08, 2011 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Unable to import text file to access table

Hey everyone, I was able to fix my problem using the following:

filnam = Me![Text2]
Set objFile = CreateObject("Scripting.FileSystemObject")
Set objText = objFile.OpenTextFile(filnam)
Set rs = CurrentDb.OpenRecordset("FlatFileImport")
once = False
If Not IsNull(Me.Text2) Then filnam = Me.Text2
Open filnam For Binary As #1
Do While Not objText.AtEndOfStream
strTextLine = objText.Readline
Data = Split(strTextLine, ",")
If once Then
rs.Fields(1) = Data(0) 'Site ID
rs.Fields(2) = Data(1) 'Client ID
rs.Fields(3) = Data(2) 'Client Name
rs.Fields(4) = Data(3) 'DDA Account
rs.Fields(5) = Data(4) 'Process Date
rs.Fields(6) = Data(5) 'Good Checks Singles
rs.Fields(7) = Data(6) 'Good Checks Stubs
rs.Fields(8) = Data(7) 'Good Checks Partial
rs.Fields(9) = Data(8) 'Good Stubs Partial
rs.Fields(10) = Data(9) 'Good Checks Multi
rs.Fields(11) = Data(10) 'Good Stubs Multi
rs.Fields(12) = Data(11) 'Check Only Checks
rs.Fields(13) = Data(12) 'Check Only Stubs
rs.Fields(14) = Data(13) 'Check And List Stubs
rs.Fields(15) = Data(14) 'Check And List Checks
rs.Fields(16) = Data(15) 'Suspense Checks
rs.Fields(17) = Data(16) 'Suspense Stubs
rs.Fields(18) = Data(17) 'Correspondence
rs.Fields(19) = Data(18) 'Envelopes
rs.Fields(20) = Data(19) 'Express Mail
rs.Fields(21) = Data(20) 'Lookup Stubs
rs.Fields(22) = Data(21) 'Online Lookups
rs.Fields(23) = Data(22) 'Stubs Only
rs.Fields(24) = Data(23) 'StopFile Hits
rs.Fields(25) = Data(24) 'SLC
rs.Fields(26) = Data(25) 'SL2
rs.Fields(27) = Data(26) 'MICR Scanline
rs.Fields(28) = Data(27) 'KeyStrokes Correspondence
rs.Fields(29) = Data(28) 'Keystrokes SLC
rs.Fields(30) = Data(29) 'Keystrokes SL2
rs.Fields(39) = Data(38) 'Exception Queue
rs.Fields(40) = Data(39) 'COA Queue

rs.Fields(41) = Data(40) 'Image Archive Reports
rs.Fields(42) = Data(41) 'Image Archive Storage

rs.Fields(43) = Data(42) 'Batches Processed

rs.Fields(44) = Data(43) 'Low Speed ARC Attempts
rs.Fields(45) = Data(44) 'High Speed ARC Attempts
rs.Fields(46) = Data(45) 'Low Speed ARC Converted
rs.Fields(47) = Data(46) 'High Speed ARC Converted

rs.Fields(48) = Data(47) 'ICL Attempts
rs.Fields(49) = Data(48) 'ICL Converted
rs.Fields(50) = Data(49) 'ICL Non-Conforming images

rs.Fields(51) = Data(50) 'Auto Returns
rs.Fields(52) = Data(51) 'Returned Items

rs.Fields(53) = Data(52) 'Positive Post Checks
rs.Fields(54) = Data(53) 'Positive Post Stubs

rs.Fields(55) = Data(54) 'Remote Payment Single Checks
rs.Fields(56) = Data(55) 'Remote Payment Single Stubs
rs.Fields(57) = Data(56) 'Remote Payment Multi Checks
rs.Fields(58) = Data(57) 'Remote Payment Multi Stubs
rs.Fields(59) = Data(58) 'Remote Payment Check Only Checks
rs.Fields(60) = Data(59) 'Remote Payment Check Only Stubs
rs.Fields(61) = Data(60) 'Remote Payment Check & List Checks
rs.Fields(62) = Data(61) 'Remote Payment Check & List Stubs

rs.Fields(71) = Data(70) 'Dollars Deposited
rs.Fields(72) = Data(71) 'PP Corro Rejects

End If

once = True
MyLine = ""
MyLine = MyLine & ch
MyLocation = Loc(1)
MsgBox " File has been successfully imported! "
Close #1 ' Close file.
'close and erase the file from memory
Set objText = Nothing
Set rs = Nothing

Sep 08, 2009 | Microsoft Access 2003 for PC

1 Answer

Using Microsoft Query to bring Access 2007 data into a spreadsheet

Try using Data > From Other Sources and select From Microsoft Query. In the Excel sheet, select the cell that you want the results to start in. Your MS Query would be pulling the data from your Access database.

May 04, 2009 | Microsoft Excel for PC

1 Answer

How to print only selected fields in ms access.

open your table in query, follow steps to do this...

1. open new query in access
2. locate the table
3. once table selected, select field name in selected table you only want to include in query
3. once finished selecting the field save the query
4. you can now view selected field in your table and print as well
5. you can edit the query anytime if you want to add or remove field
6. query will not affect your table since this is only query.

hope this will help you....

Oct 22, 2008 | Microsoft Access 2002 for PC

1 Answer

Accessing data

Dear reader

Place an ADODC control on your form in VB.
In the properties of the ADODC control goto the TAB General.
click "Use Connection String. With the button Build you can point to your database.
Thats it.

With the following code you can connect to db:

With Adodc
.RecordSource = "SELECT * From YOURTABLE"
End With

Now you have the table in the adodc control.

you can now do this:

Label1.caption = Adodc.Recordset!YOURFIELD

YOURTABLE = the name of your table in the database.
YOURFIELD = the fieldname in YOURTABLE you want to show.

Kind regards Fred.

Jul 04, 2008 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Conversion of nemeric value

If you just want to change the format to text in a query, you can use the Str function in your query. In MS Access, in the Field area of your query in Design View, you can type the following:
YourDesiredCharFieldName: Str([YourNumericFieldName]).

On the other hand, if you prefer to convert the data once and for all in your table, you can go to the Table Design View for that Table, change the Data Type of your numeric field to "Text", and close that window to save the changes. This will convert all of your data in that field from numeric to text permanently.

Jul 01, 2008 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Export data in excel shld yoeet through VB

When i first figured out how to pull data from SQL and put the results in an excel file i referenced these two articles....
Reading and writing excel file using VB.NET (
Get the Values From DataBase and Stored into excell Sheet (

This is the code i ended up using.... (check out those links to see how you need to import the ms office excel reference file with visual basic)

Const stcon As String = "Provider=SQLNCLI;server=xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxx;DataTypeCompatibility=80"
Dim stSQL As String = "select * from scs_rate_class_money where irate_book = 124 and snew_used = 'U' and sclass = '2' and splan = 'T4' and sopt_code = 'F1'"
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim fld As ADODB.Field
'Open the connection.

'Open the recordset.
With rst
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.Open(stSQL, cnt, ADODB.CursorTypeEnum.adOpenForwardOnly, _
ADODB.LockTypeEnum.adLockReadOnly , _
.ActiveConnection = Nothing 'Disconnect the Recordset.
End With
'Close the connection
cnt.Close ()
Dim exp As Export = New Export()
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim xlWBook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet )
Dim xlWSheet As Microsoft.Office.Interop.Excel.Worksheet = CType(xlWBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
Dim xlRange As Microsoft.Office.Interop.Excel.Range = CType(xlWSheet, Microsoft.Office.Interop.Excel.Worksheet).Range("A2")
Dim xlCalc As Microsoft.Office.Interop.Excel.XlCalculation
Dim i As Short

'Turn off Excel's calculation.
With xlApp
xlCalc = .Calculation
.Calculation = Microsoft.Office.Interop.Excel.XlCalculation.xlCalculationManual
End With
'Write the fieldnames.
For Each fld In rst.Fields
xlRange.Offset(0, i).Value = fld.Name
i = i + 1
'Populate the range.
xlRange.Offset(1, 0).CopyFromRecordset(rst)
'Close the recordset.
'Make Excel available to the user.
With xlApp
.Visible = True
.UserControl = True
'Restore the calculation mode.
.Calculation = xlCalc
End With
'Release variables from memory.
fld = Nothing
rst = Nothing
cnt = Nothing
xlRange = Nothing
xlWSheet = Nothing
xlWBook = Nothing
xlApp = Nothing

Jan 03, 2008 | Business & Productivity Software

1 Answer

Ms access

Stored Procedures don't exist in MS Access. You do have the following options though. Queries, which are just select or action queries. VB Code, which you can write using Query Objects as if you were writing a Visual Basic application. These can be Functions or Subroutines. In these, you would use the standard programming techniques with while and for loops, etc.

You can create complex situations combining the two of these. A function in the VB code area can accept through parameters, the single values (line by line, record by record) in a query and act on them and manipulate the values.

For example: create a query that does a select phone from address. Create a function in vb called public function StripDashesInPhone(Phone as string) which then uses VB coding to strip dashes from each phone value passed in. To make it all work, in the query on one of the field columns put "NewPhone: StripDashesInPhone([Phone])" and for every record processed in the query, the function is called with the [Phone] field value passed in to the function and the action is processed and returned.

Other than writing a function that is activated by a form button click, which opens the current db and opens a table and process it, just like in VB, this is about as close to cursors and oracle procedures as you get.

I wish it was more, but ...

Oct 09, 2007 | Microsoft Office Standard for PC

4 Answers

Running SQL queries on Excel

Another way to do it is to use the SQL Drill freeware Excel addin (

Aug 14, 2007 | Microsoft Office 2003 Basic Edition...

Not finding what you are looking for?
Microsoft Office Standard for PC Logo

Related Topics:

192 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Business & Productivity Software Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers


Level 3 Expert

18259 Answers

Sudeep Chatterjee
Sudeep Chatterjee

Level 3 Expert

3267 Answers

Are you a Microsoft Business and Productivity Software Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides