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
 

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

Similar Threads

Need help with function 3
Calculating Time 5
update tables by VBA 1
Concatenate Function 6
Function not working 3
recordset? 2
Recordset Based on Select Query 2
Recordset problem 2

Back
Top