I have an Access 97 database which is used to design tables which are then built in SQL Server 2000. As new tables and fields are added to the designs, or old ones are modified, I have VBA code which generates an SQL script to build or modify the tables as per the current designs, as well as related stored procedures. Part of the process involves determining whether or not a given table already exists in SQL Server, as the SQL code generated for it must be different for new vs. old tables. All this has worked great for over a year, for close to 200 tables. The code I am using is shown below.
All of a sudden, I am getting a bogus error message, but only for one particular table, whose name is 23 characters long and consists entirely of letters. The error message is:
Run-time error '3125': The database engine can't find 'ExistSQL'. Make sure it is a valid parameter or alias name, that it doesn't include invalid characters or punctuation, and that the name isn't too long. The error occurs on the "DoCmd.TransferDatabase" statement. "ExistSQL" is the value of the LocalName parameter, which never changes, yet the error only occurs when TableName is "FinancePaymentsComments".
Does anyone have a clue about what's going on here?
All of a sudden, I am getting a bogus error message, but only for one particular table, whose name is 23 characters long and consists entirely of letters. The error message is:
Run-time error '3125': The database engine can't find 'ExistSQL'. Make sure it is a valid parameter or alias name, that it doesn't include invalid characters or punctuation, and that the name isn't too long. The error occurs on the "DoCmd.TransferDatabase" statement. "ExistSQL" is the value of the LocalName parameter, which never changes, yet the error only occurs when TableName is "FinancePaymentsComments".
Does anyone have a clue about what's going on here?
Code:
Function ExistSQL(TableName As Variant) As Boolean
'returns a Boolean value indicating whether TableName exists in the SQL database Production
Const DatabaseType = "ODBC Database"
Const ConnString = "ODBC;WSID=PWDC-DB;Trusted_Connection=Yes;DATABASE=Production;DSN=PWDCProduction"
Const LocalName = "ExistSQL"
If IsNull(TableName) Then
ExistSQL = False
Else
'On Error GoTo ExistSQL_Err
DoCmd.TransferDatabase acLink, DatabaseType, ConnString, acTable, TableName, LocalName, True, False
ExistSQL = True
CurrentDb.TableDefs.Delete LocalName
End If
ExistSQL_Exit:
Exit Function
ExistSQL_Err:
ExistSQL = False
GoTo ExistSQL_Exit
End Function
Last edited by a moderator: