Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code raises "Type Mismatch Error" HELP!! 1

Status
Not open for further replies.

branch861

IS-IT--Management
Feb 11, 2003
14
US
I have the following code behind an A97 form. It worked fine in A2k but I keep getting a "Type Mismatch Error" with the following code. I commented out most of the lines and I keep getting the same error. I also tried moving the code to the On Load Event...no change. After commenting out line by line...It appears that it doesn't like "rstMax as Recordset". Any ideas?

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
Dim dbsMain As Database
Dim rstMax As Recordset

Forms!frmDebitOdMain.Repaint
'Determine the latest data date for the default lookup
Set dbsMain = CurrentDb
Set rstMax = dbsMain.OpenRecordset("qryGetMaxDebitOdDate")
rstMax.MoveFirst
ASOF_Date = rstMax!Max_Trans_Date
Me.txtFromDate.Value = rstMax!Max_Trans_Date
Me.txtToDate.Value = rstMax!Max_Trans_Date
rstMax.Close
'Run the query to report on Overdrafts for the default date
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryGetDebitOdBaseDataMT", acViewNormal, acReadOnly
DoCmd.SetWarnings True
cmdGo_Click
Exit Sub
Err_Form_Open:
Select Case Err.Number
Case 3151
MsgBox "ERROR " + Trim(Str(Err.Number)) + ": " + Err.Description + Chr(13) + Chr(13) + "Cannot continue without ODBC connection. Aborting..."
Quit
Case Else
MsgBox "ERROR " + Trim(Str(Err.Number)) + ": " + Err.Description
Exit Sub
End Select
End Sub
 
Sounds like a references problem.

Make sure Microsoft DA0 3.6 is checked.

You may need to preceed declarations with DAO like this:
Dim MyRecordset as DAO.Recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top