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

ADO Access 2000

Status
Not open for further replies.

johndweidauer

Programmer
Jul 31, 2002
105
US
Howdy,

Its been a while, but i am trying to retrieve the number of fields contained in my recordset and the way i have always done it (vbscript/asp/ado) is Rs.Fields.Count, but this returns 1 or 0. What have i forgotten? How do i easily get the number of fields in my recordset?
 
Hi johndweidauer,

I don't know where you're coming from but:

Rs.Fields.Count

Is the correct syntax.

Can you post your code in it's entirety, the problem must be somewhere else in your code.

Bill
 
thanks for "reading" my post bill, thanks for the help you other two, i appreciate your assistance.

As for my code:
Code:
Dim Cn As ADODB.Connection, Rs As ADODB.Recordset, sSQL As String
Dim i As Integer, fldArr(), fldTypeArr()
Dim sSQLF As String, sSQLV As String, fldSQL()
Dim MeForm As Form, strEmptyFlds As String

ReDim fldArr(0) '// Array to hold field names from tblMedicalServices
ReDim fldTypeArr(0) '// Array to hold field types of fldArr() fields
ReDim fldSQL(0) '// Array to hold values of field

On Error GoTo ins_Err:

Set Cn = CurrentProject.Connection
    
'//  WE WILL DETERMINE THE FIELD TYPES THAT WE ARE INSERTING INTO SO THAT
'     WE CAN BUILD OUR QUERY STRING CORRECTLY
Set Rs = Cn.Execute("select top 1 * from [tbl]") '// Query top row to obtain field names

strEmptyFlds = ""
'// For each field in [tbl], get field name and type
For i = 0 To Rs.Fields.Count - 1
  fldArr(i) = Rs.Fields(i).Name
  fldTypeArr(i) = Rs.Fields(i).Type

  ReDim Preserve fldArr(i + 1)
  ReDim Preserve fldTypeArr(i + 1)
Next
 
hold, i found the problem, its not the code i posted, but some code after.

Thanks folks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top