M
Mike Morgan
We're having a strange problem using Access with a SQL 2000 database. This code used to work. Somehow Access lost the reference to the DAO 3.6 library. At that point it threw an error saying that Workspace was an undefined user defined object. I added DAO 3.6 back and it again recognized the Workspace declaration. But, when it tries to open a connection (see Set HID line below) it throws a "Error 13 was generated by HID - Type Mismatch". I can't figure out why its doing this. This code worked great for the longest time. "HID" is a valid ODBC datasource. OpenConnection requires a string. HID is a connection. OpenConnection returns a connection. What am I missing?
HID is an ODBC datasource.
' From constants section
Const QryExpungeIncidentActivity = "EXECUTE ExpungeACTIVITY "
' Other unrelated subroutines are here
Private Sub btnExpunge_Click()
Dim dbHistorical As Workspace
Dim HID As Connection
Dim ExpungeQry As String
Dim Response As Integer
On Error GoTo ERRORTRAP:
Response = MsgBox("Are you sure you want to expunge this item?", vbQuestion + vbYesNo, "Expungement")
If (Response = vbYes) Then
Set dbHistorical = CreateWorkspace("HistoricalInquiries", "admin", "", dbUseODBC)
Set HID = dbHistorical.OpenConnection("HID") '------------ Throws error: Error 13 was generated by HID - Type Mismatch
ExpungeQry = QryExpungeIncidentActivity & CStr(lstExpungements.Value)
HID.Execute (ExpungeQry)
HID.Close
dbHistorical.Close
Call btnRefresh_Click
End If
Exit Sub
ERRORTRAP:
Call ErrorRoutine
Resume Next
End Sub
HID is an ODBC datasource.
' From constants section
Const QryExpungeIncidentActivity = "EXECUTE ExpungeACTIVITY "
' Other unrelated subroutines are here
Private Sub btnExpunge_Click()
Dim dbHistorical As Workspace
Dim HID As Connection
Dim ExpungeQry As String
Dim Response As Integer
On Error GoTo ERRORTRAP:
Response = MsgBox("Are you sure you want to expunge this item?", vbQuestion + vbYesNo, "Expungement")
If (Response = vbYes) Then
Set dbHistorical = CreateWorkspace("HistoricalInquiries", "admin", "", dbUseODBC)
Set HID = dbHistorical.OpenConnection("HID") '------------ Throws error: Error 13 was generated by HID - Type Mismatch
ExpungeQry = QryExpungeIncidentActivity & CStr(lstExpungements.Value)
HID.Execute (ExpungeQry)
HID.Close
dbHistorical.Close
Call btnRefresh_Click
End If
Exit Sub
ERRORTRAP:
Call ErrorRoutine
Resume Next
End Sub