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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type Mismatch 1

Status
Not open for further replies.

ggreg

Programmer
Mar 9, 2001
201
US
Below is the code, which works and runs in access97 but am trying to get it to work in
XP.....I have added DAO 2.5

is my problem:'" & rs!bad & "'

or where is the problem in this code?

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim db As Database
Dim rs As Recordset
Dim FilterCriteria As String

Set db = CurrentDb
Set rs = db.OpenRecordset("select distinct bad from Table1")

rs.MoveFirst
Do Until rs.EOF
FilterCriteria = "[bad] = '" & rs!bad & "'"
DoCmd.OpenReport "rpt1", acNormal, , FilterCriteria
rs.MoveNext
Loop

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
 
Why add such an old DAO reference?

In any case, unless you get rid of the ADO reference, which I wouldn't recommend, you'll have to do this:
Dim db As DAO.Database
Dim rs As DAO.Recordset

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Jeremy,
if I change reference what would I have to do ?
and why stay with the old reference, will give your
suggestion tomorrow
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top