Y
yorkiechris
Hi there.
I'm running Access 2003.
I'm trying to:
1) run a make table query that creates a table in the back end (no problems)
Table in the backend is called STP_BulkTransactions
2) add an autonumber field to it (no problem)
I call this function:
Function AddIDSTP(TableName As String, db As Database)
strSQL = "ALTER TABLE " & TableName & " ADD TempID Autoincrement"
db.Execute strSQL
db.TableDefs.Refresh
Set strSQL = Nothing
End Function
3) link that table to the front end (no problem)
I do this by calling:
Function AddLinkedTable(TableName As String)
Dim tdfLinked As TableDef
Set tdfLinked = CurrentDb.CreateTableDef(TableName)
tdfLinked.Connect = ";DATABASE=x:\path\to\backend.mdb"
tdfLinked.SourceTableName = TableName
CurrentDb.TableDefs.Append tdfLinked
CurrentDb.TableDefs.Refresh
End Function
4) append the data in that table to another table (after adding the DMax of
the current table (BIG PROBLEM!!)
....
varMaxBulkRef = Nz(DMax("BulkRef", "[BulkTransactions]"), 548000000)
strAppToBulk = "INSERT INTO BulkTransactions ( BulkRef, Description,
EntryType, UnitPriceRef, " & _
"LastUpdated ) SELECT " & CInt(varMaxBulkRef) & " +
STP_BulkTransactions.TempID AS Expr1,
.....
All the other fields
.....
CurrentDb.Execute strAppToBulk, dbFailOnError
This returns an error saying that the field I am trying to append to the
BulkRef field is null (which is not permitted). I've messed around with the
varMaxBulkRef - that's definitely not null. So the only thing left that could
be null is the TempID that was added by the AddIDSTP() function - but this
clearly isn't null as it's an autonumber.
Does anyone have any ideas please?
Love
yorkiechris
I'm running Access 2003.
I'm trying to:
1) run a make table query that creates a table in the back end (no problems)
Table in the backend is called STP_BulkTransactions
2) add an autonumber field to it (no problem)
I call this function:
Function AddIDSTP(TableName As String, db As Database)
strSQL = "ALTER TABLE " & TableName & " ADD TempID Autoincrement"
db.Execute strSQL
db.TableDefs.Refresh
Set strSQL = Nothing
End Function
3) link that table to the front end (no problem)
I do this by calling:
Function AddLinkedTable(TableName As String)
Dim tdfLinked As TableDef
Set tdfLinked = CurrentDb.CreateTableDef(TableName)
tdfLinked.Connect = ";DATABASE=x:\path\to\backend.mdb"
tdfLinked.SourceTableName = TableName
CurrentDb.TableDefs.Append tdfLinked
CurrentDb.TableDefs.Refresh
End Function
4) append the data in that table to another table (after adding the DMax of
the current table (BIG PROBLEM!!)
....
varMaxBulkRef = Nz(DMax("BulkRef", "[BulkTransactions]"), 548000000)
strAppToBulk = "INSERT INTO BulkTransactions ( BulkRef, Description,
EntryType, UnitPriceRef, " & _
"LastUpdated ) SELECT " & CInt(varMaxBulkRef) & " +
STP_BulkTransactions.TempID AS Expr1,
.....
All the other fields
.....
CurrentDb.Execute strAppToBulk, dbFailOnError
This returns an error saying that the field I am trying to append to the
BulkRef field is null (which is not permitted). I've messed around with the
varMaxBulkRef - that's definitely not null. So the only thing left that could
be null is the TempID that was added by the AddIDSTP() function - but this
clearly isn't null as it's an autonumber.
Does anyone have any ideas please?
Love
yorkiechris