Error 91 - with Querydefs - newbie

  • Thread starter Thread starter inarobis
  • Start date Start date
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
 
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?
 
Back
Top