Type mismatch after convert from A2003 to A2007

S

Song

In A2003, the code works. After I converted to A2007, following code give me
'type mismatch' error. It points to Set rst= line. I double check those
fields still text and same code still run in A2003.

Private Sub Sect_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("Select * From Course Where [sem] = '"
& Me.Sem & "' And [sect] = '" & Me.Sect & "'")
If rst.EOF Then
MsgBox Me.Sect & " Is not a valid Section", , conAppName
Cancel = True
Else
Me.Subj = rst![Subj]
Me.No = rst![No]
Me.Lt = rst![Lt]
End If
Set rst = Nothing

Exit_sect_BeforeUpdate:
Exit Sub
Err_sect_BeforeUpdate:
MsgBox Err.Description
Resume Exit_sect_BeforeUpdate


End Sub
 
B

Bob Barrows [MVP]

Song said:
In A2003, the code works. After I converted to A2007, following code
give me 'type mismatch' error. It points to Set rst= line. I double
check those fields still text and same code still run in A2003.

Private Sub Sect_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("Select * From Course Where

Most likely due to a lack of a Reference to the DAO library. You will
also want to do a search/replace and change all

Dim rst As Recordset

to

Dim rst As DAO.Recordset
 
S

Song

That's it! Thanks.

Bob Barrows said:
Most likely due to a lack of a Reference to the DAO library. You will
also want to do a search/replace and change all

Dim rst As Recordset

to

Dim rst As DAO.Recordset

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top