Error 91 - with Querydefs - newbie

I

inarobis

Hello Guys,

I have an error with this Form_open sub and I do not know why. The
error it is the error 91 (Object or Block variable not set) and the
line is the "Set qds = db.QueryDefs"

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim qds As DAO.QueryDefs
Dim qd As DAO.QueryDef
Dim strSql As String
Dim strName As String

'I get this value from another form
strName = Cstr(Me.OpenArgs)


'the candidate is a view
strSql = "Select [NAME] from dbo.Candidate where ([NAME] = '" & strName
& "');"

Set db = CurrentDb
Set qds = db.QueryDefs
Set qd = qds("dbo.Candidate")
qd.SQL = strSql

Set db = Nothing
End Sub

Someone can help me on that?

Ina
 
R

RoyVidar

Hello Guys,

I have an error with this Form_open sub and I do not know why. The
error it is the error 91 (Object or Block variable not set) and the
line is the "Set qds = db.QueryDefs"

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim qds As DAO.QueryDefs
Dim qd As DAO.QueryDef
Dim strSql As String
Dim strName As String

'I get this value from another form
strName = Cstr(Me.OpenArgs)


'the candidate is a view
strSql = "Select [NAME] from dbo.Candidate where ([NAME] = '" &
strName & "');"

Set db = CurrentDb
Set qds = db.QueryDefs
Set qd = qds("dbo.Candidate")
qd.SQL = strSql

Set db = Nothing
End Sub

Someone can help me on that?

Ina

Try something more like this

Set db = CurrentDb
Set qd = db.QueryDefs("dbo.Candidate")
qd.SQL = strSql

I don't use DAO much, but can you use a syntax with owner prefix
there? I thought that was more SQL Server syntax?
 

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