Forum Discussion
OK, several things.
First of all, you might have problems if the first row of your excel spreadsheet is not the column names. By default, data drivers like this use the first row to give column names so it will probably skip your first row of data. Technically, speaking, your first section of code should work fine for your needs. It will return every row for Curve1... but you need to change your data table to
| Name | Value1 | Value2 | Value3 |
| Curve1 | 20 | 3 | 1 |
| Curve1 | 30 | 3 | 1 |
| Curve1 | 40 | 3.5 | 1 |
| Curve1 | 50 | 1 | 1 |
| Curve2 | 10 | 0 | 1 |
| Curve2 | 20 | 0 | 1 |
| Curve2 | 30 | 1 | 1 |
| Curve2 | 40 | 1 | 1 |
so that the driver will recognize your actual first row of data.
As for your syntax error in your second routine... for VBScript, you don't need to use the == to do a comparison. = should be fine... but that routine will exit immediately without returning any data at all. I'd use your first routine, but fix your excel sheet to have column headers.
- ChandanD9 years agoContributor
Yes,
Itworks for first record only.
Actually what I need is
If Name=Curve1 then enter the records till the name is not Curve2 in my application
Then Create Curve2 in my application
Search Name=Curve2 or EOF then enter the records in my application.
With first code it is creating Curve1 and entering Curve 1 data
Create Curve2 but doesn't enter Curve2 data.
- tristaanogre9 years agoEsteemed Contributor
In your first routine, do the following:
Sub Temp set curvedriver = DDT.ExcelDriver(Path&"TestData\PrjData\PrjData.xlsx", "CurveData", true) name=DDT.CurrentDriver.Value(0) curvedriver.Name="Curvedriver" do addnew = DDT.DriverByName("Curvedriver").Value(0) if (addnew<>name) then name=DDT.CurrentDriver.Value(0) msgbox(DDT.DriverByName("Curvedriver").Value(1)) msgbox(DDT.DriverByName("Curvedriver").Value(2)) msgbox(DDT.DriverByName("Curvedriver").Value(3)) Call curvedriver.Next() loop until (curvedriver.EOF) Call DDT.CloseDriver(curvedriver.Name) End SubThis will loop through both sections of the table, first going through Curve1. Then, when they are different, it resets the "name" to curve 2 and goes through the data again.
- ChandanD9 years agoContributor
sub temp
Dim Driver, Path
set Driver = DDT.ExcelDriver(Path&"TestData\PrjData\PrjData.xlsx", "Curve", true)
While not Driver.EOF
crname= DDT.CurrentDriver.Value(0)
set curvedriver = DDT.ExcelDriver(Path&"TestData\PrjData\PrjData.xlsx", "CurveData", true)
curvedriver.Name="Curvedriver"
do
addnewcurve = DDT.DriverByName("Curvedriver").Value(0)
if (crname<>addnewcurve) then Exit do
msgbox(DDT.DriverByName("Curvedriver").Value(1))
msgbox(DDT.DriverByName("Curvedriver").Value(2))
msgbox(DDT.DriverByName("Curvedriver").Value(3))
Call curvedriver.Next()
loop until (curvedriver.EOF)
Call Driver.Next()
WEND
Call DDT.CloseDriver(Driver.Name)
End Sub
Still Not working.