Christian Pardun
2004-06-09 11:31:13 UTC
Hallo nochmal Zusammen,
ich habe folgende VBA-Anweisung geschrieben und bekomme
den Fehler "Typen unverträglich". Keine AHnung warum:
:Das Module:
Option Explicit
Public Cnxn As ADODB.Connection
Public Sub openDatabase()
' open the database connection
Set Cnxn = New Connection
Call Cnxn.Open
("ODBC;DATABASE=SupportSystem;UID=supportuser;PWD=ae03gm09
bx;DSN=SupportSystem", "supportuser", "ae03gm09bx", -1)
End Sub
Public Sub closeDatabase()
' close the database connection
Cnxn.Close
End Sub
Function openRecordset(strSQL As String) As Recordset
' Get the recordset
Dim rst As New Recordset
Call rst.Open(strSQL, Cnxn, adOpenForwardOnly,
adLockReadOnly, -1)
Set openRecordset = rst
End Function
----------------------------------------------------------
'Die VBA-Anweisung:
Private Sub SelectCompany_Exit(Cancel As Integer)
'On Error GoTo fehler:
Dim rst As ADODB.Recordset
Dim strQuery As String
Dim strQueryUpd As String
Dim strMessage As String
Dim strUpdateValue As Object
Dim cmdChange As ADODB.Command
Dim strSQLChange As String
' this sub is called by the report generator tool
Call DatabaseAccess.openDatabase
strQuery = "SELECT idkey FROM company WHERE
CompanyName = '" & SelectCompany.Value & "'"
Set rst = DatabaseAccess.openRecordset(strQuery)
Set strUpdateValue = rst.Fields(0)
' Create command object
Set cmdChange = New ADODB.Command
Set cmdChange.ActiveConnection = Cnxn
If Not rst.EOF Then
strSQLChange = "Update Buglist set idcompany
= '" & strUpdateValue & "'"
cmdChange.CommandText = strSQLChange
Cnxn.Execute cmdChange, rst, -1
'Cnxn.ExecuteCommand cmdChange, rst
'MsgBox strSQLChange
'MsgBox strQuery
'Set rs.Execute = DatabaseAccess.openRecordset
(strQuery)
End If
rst.Close
End Sub
ich habe folgende VBA-Anweisung geschrieben und bekomme
den Fehler "Typen unverträglich". Keine AHnung warum:
:Das Module:
Option Explicit
Public Cnxn As ADODB.Connection
Public Sub openDatabase()
' open the database connection
Set Cnxn = New Connection
Call Cnxn.Open
("ODBC;DATABASE=SupportSystem;UID=supportuser;PWD=ae03gm09
bx;DSN=SupportSystem", "supportuser", "ae03gm09bx", -1)
End Sub
Public Sub closeDatabase()
' close the database connection
Cnxn.Close
End Sub
Function openRecordset(strSQL As String) As Recordset
' Get the recordset
Dim rst As New Recordset
Call rst.Open(strSQL, Cnxn, adOpenForwardOnly,
adLockReadOnly, -1)
Set openRecordset = rst
End Function
----------------------------------------------------------
'Die VBA-Anweisung:
Private Sub SelectCompany_Exit(Cancel As Integer)
'On Error GoTo fehler:
Dim rst As ADODB.Recordset
Dim strQuery As String
Dim strQueryUpd As String
Dim strMessage As String
Dim strUpdateValue As Object
Dim cmdChange As ADODB.Command
Dim strSQLChange As String
' this sub is called by the report generator tool
Call DatabaseAccess.openDatabase
strQuery = "SELECT idkey FROM company WHERE
CompanyName = '" & SelectCompany.Value & "'"
Set rst = DatabaseAccess.openRecordset(strQuery)
Set strUpdateValue = rst.Fields(0)
' Create command object
Set cmdChange = New ADODB.Command
Set cmdChange.ActiveConnection = Cnxn
If Not rst.EOF Then
strSQLChange = "Update Buglist set idcompany
= '" & strUpdateValue & "'"
cmdChange.CommandText = strSQLChange
Cnxn.Execute cmdChange, rst, -1
'Cnxn.ExecuteCommand cmdChange, rst
'MsgBox strSQLChange
'MsgBox strQuery
'Set rs.Execute = DatabaseAccess.openRecordset
(strQuery)
End If
rst.Close
End Sub