Recordset Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code, and am not able to pull
the info out I need to update a field in another table.

Public Function TotalHoursPerDay()

Dim TotalHours As Double

Dim rstTotalHoursPerDay As DAO.Recordset

Set db = CurrentDb
Set rstTotalHoursPerDay = db.OpenRecordset("SELECT
[TotHours] as Tim FROM DateRange where [Active] = -1",
dbOpenDynaset)

rstTotalHoursPerDay.MoveFirst

Do Until rstTotalHoursPerDay.EOF
TotalHours = Tim
rstTotalHoursPerDay.MoveNext

Loop

End Function

This seems so simple, but I'm not able to get any of the
TotHours for any records. What am I missing...I'm sure
it's something very simple. I just want to update a
field in another table, but cannot get any data from this
query. Thanks for any help!

Tim
 
The line should be
TotalHours = rstTotalHoursPerDay!Tim

Hope This Helps
Gerald Stanley MCSD
 
That was it! Spent 6 hours fighting with this one.
Thank you so much!
-----Original Message-----
The line should be
TotalHours = rstTotalHoursPerDay!Tim

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I am using the following code, and am not able to pull
the info out I need to update a field in another table.

Public Function TotalHoursPerDay()

Dim TotalHours As Double

Dim rstTotalHoursPerDay As DAO.Recordset

Set db = CurrentDb
Set rstTotalHoursPerDay = db.OpenRecordset("SELECT
[TotHours] as Tim FROM DateRange where [Active] = -1",
dbOpenDynaset)

rstTotalHoursPerDay.MoveFirst

Do Until rstTotalHoursPerDay.EOF
TotalHours = Tim
rstTotalHoursPerDay.MoveNext

Loop

End Function

This seems so simple, but I'm not able to get any of the
TotHours for any records. What am I missing...I'm sure
it's something very simple. I just want to update a
field in another table, but cannot get any data from this
query. Thanks for any help!

Tim
.
.
 
I am using the following code, and am not able to pull
the info out I need to update a field in another table.

Public Function TotalHoursPerDay()

Dim TotalHours As Double

Dim rstTotalHoursPerDay As DAO.Recordset

Set db = CurrentDb
Set rstTotalHoursPerDay = db.OpenRecordset("SELECT
[TotHours] as Tim FROM DateRange where [Active] = -1",
dbOpenDynaset)

rstTotalHoursPerDay.MoveFirst

Do Until rstTotalHoursPerDay.EOF
TotalHours = Tim
rstTotalHoursPerDay.MoveNext

Loop

End Function


You're not referencing the field in the recordset.

TotalHours = rstTotalHoursPerDay!Tim
 
Back
Top