D
Debralous
I have a function that is supposed to loop through a table and update
the information in fields based on query results in a data set. I am
stumped as to why it doesn't work. Here is the section of code that
is giving me trouble:
sqlstr2 = "select * from HBPCHRG where BGCTAC = " &
rstClientInfo.Fields("mmacct")
If rstPayorInfo.State = 0 Then
rstPayorInfo.Open sqlstr2, connHNWM, adOpenDynamic,
adLockOptimistic
else
rstPayorInfo.Requery sqlstr2 (I've tried with and without the
sqlstr2 argument)
End If
If Not rstPayorInfo.EOF Then
rstMain.Fields("Payor Code #1") =
rstPayorInfo.Fields("BGCUB1")
rstMain.Fields("Plan Code #1") =
rstPayorInfo.Fields("BGCPL1")
rstMain.Fields("Payor Code #2") =
rstPayorInfo.Fields("BGCUB2")
rstMain.Fields("Plan Code #2") =
rstPayorInfo.Fields("BGCPL2")
rstMain.Fields("Payor Code #3") =
rstPayorInfo.Fields("BGCUB3")
rstMain.Fields("Plan Code #3") =
rstPayorInfo.Fields("BGCPL3")
End If
I'm omitting the extraneous code as the function does work, it just
returns the "wrong" values. "Main" is the table I'm trying to update.
I'm using values from the query of another database to get the values
for the update.
When I try to debug it does appear that I am successfully moving to the
next record; when I mouse over the rstClientInfo.Fields("mmacct") I get
the correct (next) value and when I mouse over sqlstr2 I see the
correct query statement with the "next" value but the
rstPayroInfo.Fields data retains the values from the first pass
through...essentially updating all records in the table with the values
from the first record.
Maybe Requery isn't right for what I'm trying to do? I need to be able
to loop through this and update table without closing and reopening the
recordset every time, which is the way the person who originally wrote
this had it working and it DOES work that way, however, the file is
large and that just takes too long (30 minutes or more).
Any help, suggestions are appreciated!!
the information in fields based on query results in a data set. I am
stumped as to why it doesn't work. Here is the section of code that
is giving me trouble:
sqlstr2 = "select * from HBPCHRG where BGCTAC = " &
rstClientInfo.Fields("mmacct")
If rstPayorInfo.State = 0 Then
rstPayorInfo.Open sqlstr2, connHNWM, adOpenDynamic,
adLockOptimistic
else
rstPayorInfo.Requery sqlstr2 (I've tried with and without the
sqlstr2 argument)
End If
If Not rstPayorInfo.EOF Then
rstMain.Fields("Payor Code #1") =
rstPayorInfo.Fields("BGCUB1")
rstMain.Fields("Plan Code #1") =
rstPayorInfo.Fields("BGCPL1")
rstMain.Fields("Payor Code #2") =
rstPayorInfo.Fields("BGCUB2")
rstMain.Fields("Plan Code #2") =
rstPayorInfo.Fields("BGCPL2")
rstMain.Fields("Payor Code #3") =
rstPayorInfo.Fields("BGCUB3")
rstMain.Fields("Plan Code #3") =
rstPayorInfo.Fields("BGCPL3")
End If
I'm omitting the extraneous code as the function does work, it just
returns the "wrong" values. "Main" is the table I'm trying to update.
I'm using values from the query of another database to get the values
for the update.
When I try to debug it does appear that I am successfully moving to the
next record; when I mouse over the rstClientInfo.Fields("mmacct") I get
the correct (next) value and when I mouse over sqlstr2 I see the
correct query statement with the "next" value but the
rstPayroInfo.Fields data retains the values from the first pass
through...essentially updating all records in the table with the values
from the first record.
Maybe Requery isn't right for what I'm trying to do? I need to be able
to loop through this and update table without closing and reopening the
recordset every time, which is the way the person who originally wrote
this had it working and it DOES work that way, however, the file is
large and that just takes too long (30 minutes or more).
Any help, suggestions are appreciated!!