PDA

Click to See Complete Forum and Search --> : Accessing records from a Data Env. w/ child commands


CSapo
Apr 2nd, 2000, 10:11 PM
Greetings, relatively new to VB, so please excuse the simplicity of this question.

I'm trying to create a small app that will write out a text file from a SQL Server database, using a Data Environment with several child commands to bring back the records.

Normally, I would just reference the fields as such:

Brand = deACProd.rscdMainFields.Fields("Brand")
Model = deACProd.rscdMainFields.Fields("Model")
Status = deACProd.rscdMainFields.Fields("Status")

Etc. However, let's say my "Model" and "Status" fields are actually returned by the child command. Once I get to Model (when trying to 'run' my app), it will collapse b/c it doesn't see the child command field as a "field" in the recordset.

The following code will actually loop through the child commands, and retrieve the appropriate data *until* it hits a records where the first child command field (Model, for example) is null (empty?). Then the app (and VB if running in debug) just closes without any error or anything.

Dim intCount As Long
Dim crs As Variant 'child record set
Dim iFieldCount As Long

intCount = 7
Features = ""

Do While intCount < deACProd.rscdMainFields.Fields.Count
Set crs = deACProd.rscdMainFields.Fields(intCount)

iFieldCount = 0

Do While iFieldCount < crs.Value.Fields.Count
' Debug.Print , crs.Value.Fields(iFieldCount)

Features = Features & crs.Value.Fields(iFieldCount) & Chr(9)
iFieldCount = iFieldCount + 1
Loop

intCount = intCount + crs.Value.Fields.Count
Loop

Set crs = Nothing

Any help would be greatly appreciated. Thanks!!

Cindy