A
Al
The case:
I wrote the following code to do the following:
1) to import a sheet and range from excel
2) Name the imported table “AllGenes”
3) Using 3 append qrys, I take the appropriate data from
the “AllGenes” table to append 3 tables in the database
4) Then renaming the “AllGenes” to “AllGenes_Date_time”
ex. AllGenes_7-11-03 5:30 PM so that I can use
the “AllGenes” name again to keep the Append qrys working
without having to change the table name.
The Problem:
Step 4 does not work successfully every time and I always
get an error message at the end saying:
Errorr0)
I do not think that the error message has anything to do
with the failure of renaming the “AllGenes” table. Any
ideas?
The code:
Private Sub Command4_Click()
On Error GoTo ErrHandler
Dim Db As Database
Dim tdf As TableDef
Dim tblName As String
Dim intI As Integer
Dim intNumTbls As Integer
Set Db = OpenDatabase("GeneArrayMgr97.mdb")
Db.TableDefs.Refresh
intNumTbls = Db.TableDefs.Count
If IsNull(Me![DirName]) Or IsNull(Me!
[SheetRangeName]) _
Or IsNull(Me![NewTableName]) Or IsNull(Me!
[DrugName]) _
Or IsNull(Me![DrugConc]) Or IsNull(Me![RunNo]) Or
IsNull(Me![PrepDate]) Then
MsgBox "You can not leave any field blank!
Please fill appropriate fields"
Else
DoCmd.TransferSpreadsheet acImport, 8,
Me![NewTableName], Me![DirName], True, Me![SheetRangeName]
DoCmd.OpenQuery "qryPopulateFilterTable"
DoCmd.OpenQuery "qryPopulateFilterDetailsTable"
DoCmd.OpenQuery "qryPopulateCorrectionsTable"
For intI = 0 To intNumTbls - 1
Set tdf = Db.TableDefs(intI)
If tdf.Name = "AllGenes" Then
tdf.Name = tdf.Name & "_" & Format(Now
())
Else
End If
Next intI
End If
ErrHandler:
MsgBox "Error: " & Err.Description & " (" & Err.Number
& ")"
'Resume
End Sub
***************
Thanks
Al
I wrote the following code to do the following:
1) to import a sheet and range from excel
2) Name the imported table “AllGenes”
3) Using 3 append qrys, I take the appropriate data from
the “AllGenes” table to append 3 tables in the database
4) Then renaming the “AllGenes” to “AllGenes_Date_time”
ex. AllGenes_7-11-03 5:30 PM so that I can use
the “AllGenes” name again to keep the Append qrys working
without having to change the table name.
The Problem:
Step 4 does not work successfully every time and I always
get an error message at the end saying:
Errorr0)
I do not think that the error message has anything to do
with the failure of renaming the “AllGenes” table. Any
ideas?
The code:
Private Sub Command4_Click()
On Error GoTo ErrHandler
Dim Db As Database
Dim tdf As TableDef
Dim tblName As String
Dim intI As Integer
Dim intNumTbls As Integer
Set Db = OpenDatabase("GeneArrayMgr97.mdb")
Db.TableDefs.Refresh
intNumTbls = Db.TableDefs.Count
If IsNull(Me![DirName]) Or IsNull(Me!
[SheetRangeName]) _
Or IsNull(Me![NewTableName]) Or IsNull(Me!
[DrugName]) _
Or IsNull(Me![DrugConc]) Or IsNull(Me![RunNo]) Or
IsNull(Me![PrepDate]) Then
MsgBox "You can not leave any field blank!
Please fill appropriate fields"
Else
DoCmd.TransferSpreadsheet acImport, 8,
Me![NewTableName], Me![DirName], True, Me![SheetRangeName]
DoCmd.OpenQuery "qryPopulateFilterTable"
DoCmd.OpenQuery "qryPopulateFilterDetailsTable"
DoCmd.OpenQuery "qryPopulateCorrectionsTable"
For intI = 0 To intNumTbls - 1
Set tdf = Db.TableDefs(intI)
If tdf.Name = "AllGenes" Then
tdf.Name = tdf.Name & "_" & Format(Now
())
Else
End If
Next intI
End If
ErrHandler:
MsgBox "Error: " & Err.Description & " (" & Err.Number
& ")"
'Resume
End Sub
***************
Thanks
Al