Couple things. Make sure the query name is spelled right and that you can open it manually. Also,
if the query is using parameters this will not work. And if it's an
Action query (INSERT INTO, UPDATE or DELETE) you will need to either use the docmd.OpenQuery or
execute via a QueryDef
Dim db as DAO.Database
Dim qdfChange As DAO.QueryDef
Set db = CurrentDb()
Set qd = db.OpenQueryDef(queryname)
qd.Execute
qd.Close
--
Reggie
----------
"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@newsg3.svr.pol.co.uk...
Something just went wrong on my server isp end hence the three identical
posts my apologies this WAS NOT an attempt to get attention.
regards
"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news6.svr.pol.co.uk... Interestingly Jeff it now give :
Object variable or With block variable not set (Error 91)
the help section wasnt very helpful on this error.
"Jeff Smith" <No***@Not.This.Address> wrote in message
news:ci**********@lust.ihug.co.nz... >
> "Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
> news:ci**********@news5.svr.pol.co.uk...
> > here it is just to clarify
> >
> > Dim db As DAO.Database
> > Dim Rst3 As DAO.Recordset
> > Set db = CurrentDb
> >
> > ******************
> > Set Rst2 = db.OpenRecordset(StrSelectPrior)
> > Rst2.MoveLast
> > Me.TxtPrior.Value = Rst2.RecordCount
> >
> > This section works
> > ***********************
> > this doesnt
> > Set Rst3 = db.OpenRecordset("Myqueryindatabase")
> >
> >
> > the reference section has the dao reference checked.
> >
> >
> > kind regards
> > Peter
>
>
> Try Set Rst3 = db.OpenRecordset("Myqueryindatabase", dbOpenDynaset)
>
> If you leave the second argument blank it assumes that the source is a
table > which is why you're getting the error. Have a look in the VBA help file
for > OpenRecordset.
>
> Jeff
>
>