dbTalk Databases Forums  

Getting no records in Rst object

comp.databases.ms-access comp.databases.ms-access


Discuss Getting no records in Rst object in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MLH
 
Posts: n/a

Default Getting no records in Rst object - 01-23-2008 , 09:28 AM






The SQL string returns 4 records if pasted into a QBE grid and run
manually. But in this DAO setting, I can't seem to get it to retrun
any records. When line #340 executes, error tells me No Current
Record. Ideas?

160 PString = "SELECT tblVehicleJobs.VehicleJobID,
tblVehicleJobs.ProcFee, tblVehicleJobs.VehicActive,
tblVehicleJobs.BilledOut FROM tblVehicleJobs "
180 PString = PString & "WHERE tblVehicleJobs.BilledOut=False AND
GetPortionPaid([VehicleJobID]>=[ProcFee]) AND
tblVehicleJobs.VehicActive=True"
240 Dim DB As Database, Rst As Recordset, QD As QueryDef
260 Set DB = CurrentDb
280 Set QD = DB.CreateQueryDef("", PString)
300 Set Rst = QD.OpenRecordset(dbOpenDynaset)
340 Rst.MoveFirst


Reply With Quote
  #2  
Old   
Fred Zuckerman
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 09:50 AM






"MLH" <CRCI (AT) NorthState (DOT) net> wrote

Quote:
The SQL string returns 4 records if pasted into a QBE grid and run
manually. But in this DAO setting, I can't seem to get it to retrun
any records. When line #340 executes, error tells me No Current
Record. Ideas?

160 PString = "SELECT tblVehicleJobs.VehicleJobID,
tblVehicleJobs.ProcFee, tblVehicleJobs.VehicActive,
tblVehicleJobs.BilledOut FROM tblVehicleJobs "
180 PString = PString & "WHERE tblVehicleJobs.BilledOut=False AND
GetPortionPaid([VehicleJobID]>=[ProcFee]) AND
tblVehicleJobs.VehicActive=True"
240 Dim DB As Database, Rst As Recordset, QD As QueryDef
260 Set DB = CurrentDb
280 Set QD = DB.CreateQueryDef("", PString)
300 Set Rst = QD.OpenRecordset(dbOpenDynaset)
340 Rst.MoveFirst
I would write the code as:

Dim rst as DAO.Recordset
Set rst = CurentDB.OpenRecordset(PString)
rst.MoveFirst

Fred Zuckerman




Reply With Quote
  #3  
Old   
MLH
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 09:52 AM



Yep, I've seen the DAO.Recordset thing before. Why is
it better to declare it that way - as opposed to simply
declaring it AS RecordSet?

Oh, and BTW, the SQL string had a misplaced parentheses
that was causing my screw-up.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


On Wed, 23 Jan 2008 07:50:04 -0800, "Fred Zuckerman"
<ZuckermanF (AT) sbcglobal (DOT) net> wrote:

Quote:
DAO.Recordset


Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 10:17 AM



MLH wrote:

Quote:
The SQL string returns 4 records if pasted into a QBE grid and run
manually. But in this DAO setting, I can't seem to get it to retrun
any records. When line #340 executes, error tells me No Current
Record. Ideas?

160 PString = "SELECT tblVehicleJobs.VehicleJobID,
tblVehicleJobs.ProcFee, tblVehicleJobs.VehicActive,
tblVehicleJobs.BilledOut FROM tblVehicleJobs "
180 PString = PString & "WHERE tblVehicleJobs.BilledOut=False AND
GetPortionPaid([VehicleJobID]>=[ProcFee]) AND
tblVehicleJobs.VehicActive=True"
240 Dim DB As Database, Rst As Recordset, QD As QueryDef
260 Set DB = CurrentDb
280 Set QD = DB.CreateQueryDef("", PString)
300 Set Rst = QD.OpenRecordset(dbOpenDynaset)
340 Rst.MoveFirst

Why not create a querydef at 280 (give it a name) and exit on 281 (exit
sub) and attempt to run the query?

North Shore
http://www.youtube.com/watch?v=BicBocJhYW8


Reply With Quote
  #5  
Old   
Fred Zuckerman
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 10:17 AM



Quote:
On Wed, 23 Jan 2008 07:50:04 -0800, "Fred Zuckerman"
ZuckermanF (AT) sbcglobal (DOT) net> wrote:

DAO.Recordset


Quote:
"MLH" <CRCI (AT) NorthState (DOT) net> wrote in message
news:9ioep3polan0n4se46m498ai6sjhiilc29 (AT) 4ax (DOT) com...
Yep, I've seen the DAO.Recordset thing before. Why is
it better to declare it that way - as opposed to simply
declaring it AS RecordSet?

Oh, and BTW, the SQL string had a misplaced parentheses
that was causing my screw-up.

I'm a little clue-less about recordsets, I've learned the technique by
reading this group. I've NEVER seen the QueryDef technique that was in your
OP.
Fred




Reply With Quote
  #6  
Old   
lyle fairfield
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 12:52 PM



MLH <CRCI (AT) NorthState (DOT) net> wrote in news:r1nep3tggrnoov0kt2lg56obbceb4cp6dn@
4ax.com:

Quote:
GetPortionPaid([VehicleJobID]>=[ProcFee])
Really?

and not

GetPortionPaid([VehicleJobID])>=[ProcFee]

?


Reply With Quote
  #7  
Old   
Bob Quintal
 
Posts: n/a

Default Re: Getting no records in Rst object - 01-23-2008 , 04:55 PM



MLH <CRCI (AT) NorthState (DOT) net> wrote in
news:9ioep3polan0n4se46m498ai6sjhiilc29 (AT) 4ax (DOT) com:

Quote:
Yep, I've seen the DAO.Recordset thing before. Why is
it better to declare it that way - as opposed to simply
declaring it AS RecordSet?
The DAO (Data Access Object) has a child recordset object and ADOdb
(Access Database Object) also has a child recordset object.
Access 2000, introduced the ADOdb object
Different installations of Access reference the two objects in
different orders. Access uses the one with higher priority unless
you specify which by specifying the DAO/ADOdb reference to force the
correct type.



Quote:
Oh, and BTW, the SQL string had a misplaced parentheses
that was causing my screw-up.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


On Wed, 23 Jan 2008 07:50:04 -0800, "Fred Zuckerman"
ZuckermanF (AT) sbcglobal (DOT) net> wrote:

DAO.Recordset



--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.