7.0 DB imported to 10.0

P

phillip9

Hello,

I'm having problems with forms & VBA imported from Access 7.0.

I'm getting compiler errors on lines that appear to be fine, such as the
following:

set rs2 = currentdb().openrecordset(strsql2, dbopensnapshot)
ERROR "compile error: variable not defined) error is highlighting
(dbopensnapshot)

I also get errors on lines that are trying to DIM DB as DATABASE
ERRROR "user-defined type not defined" error is highlighting (db as
DATABASE)

Anything would help me a lot, thanks.

-----------------------------------------
CODE:
-------------------------------------------

Private Sub txtIndex_Click()
Dim rs As RECORDSET
Dim rs2 As RECORDSET
Dim db As DATABASE
Dim strSQL2 As String

Set db = CurrentDb()

If IsNull(txtIndex.Value) Or txtIndex.Value = "" Then
Exit Sub
End If

strSQL2 = "SELECT * FROM 2530 ORDER BY projnum"

Set rs = db.openrecordset("proi", dbopensnapshot)
Set rs2 = db.openrecordset(strSQL2, dbopensnapshot)


rs2.findfirst "index = " & txtIndex




If rs2.nomatch Then
Exit Sub
Else
txtProjnum = rs2!PROJNUM
txtPrincipals = rs2!principals
txtReceivedDate = rs2!receiveddate
txtAppsCheck = rs2!appscheck
TXTSentToDetroit = rs2!senttodetroit
txtSentToHQ = rs2!senttohq
txtReceivedBack = rs2!receivedback
txtCleared = rs2!cleared

End If

rs.findfirst "projnum = '" & txtProjnum & "'"
If rs.nomatch Then
txtProjname = ""
txtServicer = ""
Else
txtProjname = rs!PROJNAME
txtServicer = rs!SERVICER
End If




rs.Close
rs2.Close

txtPrincipals.Visible = True
txtPrincipals.Enabled = True
txtPrincipals.Locked = False
End Sub
 
T

Ted Allen

Sounds like you need to add a reference to DAO (from
Tools|References in the code window). Later versions of
Access (starting in 2K I think) default the reference to
ADO rather than DAO. If you don't use ADO, you can
uncheck the reference to it. If you do leave a reference
to both, please note that they share some common object
names (such as Recordset), so you should explicitly
define these when dimensioning them such as

Dim db as DAO.Database
Dim rst as DAO.recordset
etc.

Actually, this is a good idea even if you don't keep
references to both because you never know if you may want
to change them in the future. Also, this tells VB
exactly what library to look in so that it doesn't have
to search through them.

HTH, Ted Allen
 

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