Digital Oatmeal
Registered User.
- Local time
- Yesterday, 22:56
- Joined
- May 17, 2011
- Messages
- 15
I am working in 2007 trying to create a collection for consolidating a lot of the code in my module.
Here a sample of the code from my forms:
Now mind you I am a hack programmer subject to doing totally retarded things so please be nice. I think I can pass this collection as an argument and explode it into all kinds of SQL statements. I just have to change the array of form elements for each form so it would really cut down on the coding. I name all of my controls exactly as their table names so the fieldsArray is multipurpose. I'm basically trying to create key value coding in VBA for each of my forms.
***The code fails at
on the forth line from the bottom of the code. I get a "Subscript out of range" error but I cannot figure out why. There is data in dataVar by the way.
Thanks ahead of time for any help.
Here a sample of the code from my forms:
Code:
Option Compare Database
Private fieldsArray() As String
Private dataArray() As Variant
Private recOrdno As Variant
Private USCollection As New Collection
Private Sub CreateUSDictionary()
CreateFieldsArray
CreateDataArray
For i = 0 To UBound(fieldsArray)
If IsNull(dataArray(i)) = False Then
USDictionary.Add fieldsArray(i), dataArray(i)
End If
Next i
End Sub
Private Sub CreateFieldsArray()
Dim strVar As String
strVar = "Vendname,Description,DroppedTrailer,Location,Carrier,Tankno,StartGauge,StopGauge," _
& "MicroMotionMeter,MicroMotion,TruckNumber,TrailerNumber,WeightIn1,TimeIn1,WeightOut1," _
& "TimeOut1,TruckNumber2,WeightIn2,TimeIn2,WeightOut2,TimeOut2,SealNumbers,Comments"
fieldsArray = Split(strVar, ",")
End Sub
Private Sub CreateDataArray()
Dim dataVar As Variant
For i = 0 To UBound(fieldsArray)
dataVar = Forms).Value
If IsNull(dataVar) = True Then
dataVar = "foo"
Else
dataArray(i) = dataVar
End If
Next i
End Sub

***The code fails at
Code:
dataArray(i) = dataVar
Thanks ahead of time for any help.