Due to security requirements of my application, linked tables are not allowed.
I can create a pass through query to SQL Server and retrieve results.
I can set a forms record source to an ADODB connected query IF related table is linked. The same query does not work if the linked table is removed.
'
Dim strSQL As String
10 On Error GoTo ErrorHandler
20 CurrentISO.ISOID = 2
30 SetConnection
40 strSQL = "SELECT * FROM tblISOComponent WHERE ISO_ID = " & CurrentISO.ISOID
50 RecordSource_rs.Open strSQL, RecordSource_Cnn, adOpenDynamic
60 Me.RecordSource = RecordSource_rs.Source
70 On Error GoTo 0
80 Exit Sub
ErrorHandler:
Dim strErrMsg As String
90 strErrMsg = "Error " & Err.Number & " (" & Err.Description & ") " & vbCrLf & _
"In procedure: Form_Load of Form_frmComponents" & vbCrLf & _
"Error Line: " & Erl
100 SendError strErrMsg
End Sub
Public RecordSource_Cnn As ADODB.Connection
Public RecordSource_rs As ADODB.Recordset
Public Function SetConnection()
Dim strPWD As String
strPWD = "MyPassword"
AppState.ConnectionString = "driver={SQL Server};server=SomeUser-PC\SQLEXPRESS;uid=db-RetroPMI_rw;pwd=" & strPWD & ";database=RFMSApplicationServer"
Set RecordSource_Cnn = New ADODB.Connection
RecordSource_Cnn.ConnectionString = AppState.ConnectionString
RecordSource_Cnn.Open
Set RecordSource_rs = New ADODB.Recordset
End Function
This is the error message:
[FONT="]Error 2580 (The record source 'SELECT * FROM tblISOComponent WHERE ISO_ID = 2' specified on this form or report does not exist. ) [/FONT]
I can create a pass through query to SQL Server and retrieve results.
I can set a forms record source to an ADODB connected query IF related table is linked. The same query does not work if the linked table is removed.
- Form is unbound
'
Dim strSQL As String
10 On Error GoTo ErrorHandler
20 CurrentISO.ISOID = 2
30 SetConnection
40 strSQL = "SELECT * FROM tblISOComponent WHERE ISO_ID = " & CurrentISO.ISOID
50 RecordSource_rs.Open strSQL, RecordSource_Cnn, adOpenDynamic
60 Me.RecordSource = RecordSource_rs.Source
70 On Error GoTo 0
80 Exit Sub
ErrorHandler:
Dim strErrMsg As String
90 strErrMsg = "Error " & Err.Number & " (" & Err.Description & ") " & vbCrLf & _
"In procedure: Form_Load of Form_frmComponents" & vbCrLf & _
"Error Line: " & Erl
100 SendError strErrMsg
End Sub
Public RecordSource_Cnn As ADODB.Connection
Public RecordSource_rs As ADODB.Recordset
Public Function SetConnection()
Dim strPWD As String
strPWD = "MyPassword"
AppState.ConnectionString = "driver={SQL Server};server=SomeUser-PC\SQLEXPRESS;uid=db-RetroPMI_rw;pwd=" & strPWD & ";database=RFMSApplicationServer"
Set RecordSource_Cnn = New ADODB.Connection
RecordSource_Cnn.ConnectionString = AppState.ConnectionString
RecordSource_Cnn.Open
Set RecordSource_rs = New ADODB.Recordset
End Function
This is the error message:
[FONT="]Error 2580 (The record source 'SELECT * FROM tblISOComponent WHERE ISO_ID = 2' specified on this form or report does not exist. ) [/FONT]
Last edited: