Hello
I have an Excel xlsm file in which users can pick options for a report, then generate a worksheet that includes data pulled from a database. When the user first attempts to generate a report (worksheet), the worksheet starts to load with some hard coded values, then should load with data from the database. Instead, the user sees this message:
Run-time error '3151':
ODBC-connection to 'SQL.Servermid.sqldb.prod.ton.com' failed.
This is the debug code that gets highlighted in a module called A_Func
Set RSBN = DBM.OpenRecordset("SELECT BN_ID, BN_NAME FROM dbo_BASE_NODE WHERE HN_RID =" & HN_RID, dbOpenSnapshot)
If the user closes the failed worksheet, goes back to the report option selection screen, makes their selections, the report will successfully complete.
The error began happeining after code in a module further down in the vba module hierarchy was modified. I am assuming the code processes modules in the order they appear in the VBA tree. So am not sure why the connection fails when none of the code in the A_Func module (the one that displays the highlighted code that failed) was modified.
Does anyone have any ideas on why the report creation errors the first time, but runs the second time? And where one would look to fix the problem?
I have an Excel xlsm file in which users can pick options for a report, then generate a worksheet that includes data pulled from a database. When the user first attempts to generate a report (worksheet), the worksheet starts to load with some hard coded values, then should load with data from the database. Instead, the user sees this message:
Run-time error '3151':
ODBC-connection to 'SQL.Servermid.sqldb.prod.ton.com' failed.
This is the debug code that gets highlighted in a module called A_Func
Set RSBN = DBM.OpenRecordset("SELECT BN_ID, BN_NAME FROM dbo_BASE_NODE WHERE HN_RID =" & HN_RID, dbOpenSnapshot)
If the user closes the failed worksheet, goes back to the report option selection screen, makes their selections, the report will successfully complete.
The error began happeining after code in a module further down in the vba module hierarchy was modified. I am assuming the code processes modules in the order they appear in the VBA tree. So am not sure why the connection fails when none of the code in the A_Func module (the one that displays the highlighted code that failed) was modified.
Does anyone have any ideas on why the report creation errors the first time, but runs the second time? And where one would look to fix the problem?