Don't give up yet.
I modified your code from tyour first post and was able to create a new table in the current dB.
One problem was that you had
Code:
On Error Resume Next
so that you were not notified of any errors.
Then you had lines like
Code:
Set FD = .CreateField("FixtComplete_Pct", dbLong)
FD.DecimalPlaces = 2
.Fields.Append FD
"dbLong" is a Long Integer!! An integer DOES NOT have decimals.
I commented out the On Error line and the decimal places lines.
When I executed the code..... TaDa!!
I had a new table. (had to refresh the database window to see it)
I used the current database instead of opening a different dB.
Here is the code
Code:
'_______________tbeTypeDetails_AtticStock
Function CreateAtticStockOnBackEnd() As Boolean
Dim db As DAO.Database
Dim Td As DAO.TableDef
Dim FD As DAO.Field
Dim DbPath As Variant
Dim TdName As Variant
' On Error Resume Next
'DbPath = filepath
TdName = "tbeTypeDetails_AtticStock"
'Initialize the table.
Set db = CurrentDb
'Set db = OpenDatabase(DbPath)
Set Td = db.CreateTableDef(TdName)
'Specify the fields.
With Td
Set FD = .CreateField("Type", dbText, 15) 'yeah, I know "type" is not a good name to use, but its currently ALL OVER THE PROJECT, so.....
.Fields.Append FD
Set FD = .CreateField("AtticStockYN", dbBoolean)
FD.DefaultValue = 0
.Fields.Append FD
' ________________________
'***** it's the following lines that are giving be angst '***** ________________________
Set FD = .CreateField("QtyBasis", dbLong)
.Fields.Append FD
Set FD = .CreateField("FixtComplete_Pct", dbLong)
' FD.DecimalPlaces = 2
.Fields.Append FD
Set FD = .CreateField("FixtComplete_Min", dbLong)
' FD.DecimalPlaces = 0
.Fields.Append FD
Set FD = .CreateField("Driver_Pct", dbLong)
' FD.DecimalPlaces = 2
.Fields.Append FD
Set FD = .CreateField("Driver_Min", dbLong)
' FD.DecimalPlaces = 0
.Fields.Append FD
Set FD = .CreateField("Module_Pct", dbLong)
' FD.DecimalPlaces = 2
.Fields.Append FD
Set FD = .CreateField("Module_Min", dbLong)
' FD.DecimalPlaces = 0
.Fields.Append FD
Set FD = .CreateField("Trim_Pct", dbLong)
' FD.DecimalPlaces = 2
.Fields.Append FD
Set FD = .CreateField("Trim_Min", dbLong)
' FD.DecimalPlaces = 0
.Fields.Append FD
'***** ________________________
End With
'Save the table.
db.TableDefs.Append Td
' Set FD = Nothing
' Set Td = Nothing
'Clean up
Set FD = Nothing
Set Td = Nothing
Set db = Nothing
End Function
'yeah, I know "type" is not a good name to use, but its currently ALL OVER THE PROJECT, so.....
But that is Not a good reason to keep using a bad name..... just sayin....
Good luck with your project....