Benjaminvh
Registered User.
- Local time
- Today, 02:05
- Joined
- Mar 11, 2009
- Messages
- 17
Hi all.
Hopefully someone will have the answer I am looking for
I have an existing databade (db1) and table (t1). I want to perform calculations for each record and then create a new database and table (db2 and t2) to dump the data in. t2 will have all the same fields as the first table, except for the added calculated fields.
The way I went about it was to assign the cell values in t1 to variables. This is useful for me since some intense manipulation needs to happen. After the calculations, I want to transfer all the cell values to t2.
I thought to try something like:
Set TempDBse = OpenDatabase([ExpPath] & [ExpFile_Temp])
Set TempTable = TempDBse.OpenRecordset([ExpTable_Temp], dbOpenTable)
With TempTable
TempTable.AddNew
TempTable("PRODUCT_CODE").Value = Prod
TempTable("AGE_AT_ENTRY").Value = AgeEntry
TempTable("SEX").Value = Sex
TempTable("IRP_MKR").Value = IRP
TempTable("SMOKER_STAT").Value = SmokerS
TempTable("DB_OCC_CLASS").Value = DisOccClass
End With
Set TempTable = Nothing
TempTable.Close
Set Table = Nothing
This isn't working. I get runtime error 91 (with block variable...). In any case, I'm new to VBA and don't know if this code is doing what I want it to.
Also, is it possible to create a table (t3) where the fields in t3 are a subset of the fields in t1 and have the variable values (e.g. Prod) dumped in the correct field (i.e. the programme won't dump a particular variable's value if its relevant field is excluded from t3)?
Thanks
Much much appreciated
Hopefully someone will have the answer I am looking for

I have an existing databade (db1) and table (t1). I want to perform calculations for each record and then create a new database and table (db2 and t2) to dump the data in. t2 will have all the same fields as the first table, except for the added calculated fields.
The way I went about it was to assign the cell values in t1 to variables. This is useful for me since some intense manipulation needs to happen. After the calculations, I want to transfer all the cell values to t2.
I thought to try something like:
Set TempDBse = OpenDatabase([ExpPath] & [ExpFile_Temp])
Set TempTable = TempDBse.OpenRecordset([ExpTable_Temp], dbOpenTable)
With TempTable
TempTable.AddNew
TempTable("PRODUCT_CODE").Value = Prod
TempTable("AGE_AT_ENTRY").Value = AgeEntry
TempTable("SEX").Value = Sex
TempTable("IRP_MKR").Value = IRP
TempTable("SMOKER_STAT").Value = SmokerS
TempTable("DB_OCC_CLASS").Value = DisOccClass
End With
Set TempTable = Nothing
TempTable.Close
Set Table = Nothing
This isn't working. I get runtime error 91 (with block variable...). In any case, I'm new to VBA and don't know if this code is doing what I want it to.
Also, is it possible to create a table (t3) where the fields in t3 are a subset of the fields in t1 and have the variable values (e.g. Prod) dumped in the correct field (i.e. the programme won't dump a particular variable's value if its relevant field is excluded from t3)?
Thanks
Much much appreciated