Skip to content

Commit c1f06bf

Browse files
committed
Bug fixed: information about number of fields was not correctly mapped.
This bug caused erratic behavior at import stage and in the dump methods to spreadsheets and databases when the user indicated the fields to be imported.
1 parent 998c1f0 commit c1f06bf

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/Access_version.zip

-206 Bytes
Binary file not shown.

src/CSVinterface.cls

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,13 @@ End Function
786786
Private Function GetHeaderIndexes(ByRef tmpFilters() As Variant, _
787787
ByRef header As CSVArrayList) As Long()
788788
Dim tmpResult() As Long
789+
Dim headerFieldsCount As Long
789790
Dim tmpColl As Collection
790791
Dim trqidx As Long, arridx As Long
791792
Dim matchFound As Boolean
792-
793+
793794
If Not header Is Nothing Then
795+
headerFieldsCount = UBound(header(0))
794796
Set tmpColl = New Collection
795797
For trqidx = LBound(tmpFilters) To UBound(tmpFilters)
796798
If IsNumeric(tmpFilters(trqidx)) Then
@@ -805,7 +807,7 @@ Private Function GetHeaderIndexes(ByRef tmpFilters() As Variant, _
805807
tmpColl.Add CStr(arridx + 1), CStr(arridx + 1)
806808
End If
807809
arridx = arridx + 1
808-
Loop While Not matchFound And arridx <= header.count - 1
810+
Loop While Not matchFound And arridx <= headerFieldsCount
809811
End If
810812
Next trqidx
811813
If tmpColl.count >= 1 Then
@@ -1341,14 +1343,14 @@ Public Function GetRecord() As CSVArrayList
13411343
Loop While (Not static_RecordEndReached And Not static_EndOF)
13421344
Select Case static_fieldsBound
13431345
Case Is > 0
1344-
If static_FieldID - 1 > static_fieldsMaxBound Then
1345-
static_fieldsMaxBound = static_FieldID - 1
1346+
If static_RecordToken.count - 1 > static_fieldsMaxBound Then
1347+
static_fieldsMaxBound = static_RecordToken.count - 1
13461348
static_RecordToken.ShrinkBuffer
13471349
End If
13481350
Case Else
13491351
Select Case static_FieldID
13501352
Case Is > 0
1351-
static_fieldsBound = static_FieldID - 1
1353+
static_fieldsBound = static_RecordToken.count - 1
13521354
static_RecordToken.ShrinkBuffer
13531355
Case Else
13541356
static_fieldsBound = static_FieldID
@@ -2744,14 +2746,14 @@ Private Sub ParseCSVstring(ByRef CSVtext As String, _
27442746
Loop While (Not RecordEndReached And Not EndOfString)
27452747
Select Case P_VECTORS_REGULAR_BOUND
27462748
Case Is > 0
2747-
If FieldID - 1 > P_VECTORS_MAX_BOUND Then
2748-
P_VECTORS_MAX_BOUND = FieldID - 1
2749+
If RecordToken.count - 1 > P_VECTORS_MAX_BOUND Then
2750+
P_VECTORS_MAX_BOUND = RecordToken.count - 1
27492751
RecordToken.ShrinkBuffer
27502752
End If
27512753
Case Else
27522754
Select Case FieldID
27532755
Case Is > 0
2754-
P_VECTORS_REGULAR_BOUND = FieldID - 1
2756+
P_VECTORS_REGULAR_BOUND = RecordToken.count - 1
27552757
RecordToken.ShrinkBuffer
27562758
Case Else
27572759
P_VECTORS_REGULAR_BOUND = FieldID
@@ -3841,14 +3843,14 @@ Private Sub StreamParseCSV(configObj As CSVparserConfig, _
38413843
Loop While (Not RecordEndReached And Not EndOF)
38423844
Select Case P_VECTORS_REGULAR_BOUND
38433845
Case Is > 0
3844-
If FieldID - 1 > P_VECTORS_MAX_BOUND Then
3845-
P_VECTORS_MAX_BOUND = FieldID - 1
3846+
If RecordToken.count - 1 > P_VECTORS_MAX_BOUND Then
3847+
P_VECTORS_MAX_BOUND = RecordToken.count - 1
38463848
RecordToken.ShrinkBuffer
38473849
End If
38483850
Case Else
38493851
Select Case FieldID
38503852
Case Is > 0
3851-
P_VECTORS_REGULAR_BOUND = FieldID - 1
3853+
P_VECTORS_REGULAR_BOUND = RecordToken.count - 1
38523854
RecordToken.ShrinkBuffer
38533855
Case Else
38543856
P_VECTORS_REGULAR_BOUND = FieldID

0 commit comments

Comments
 (0)