data entries

A

Alex

Hi guys,

The last entries in [UsedUnits] and [UsedKG] (and
[RecUnits] and [RecKG]) are not being updated in a table
and form. I'm using a continuous form.

Set dbs = CurrentDb

Set rstRecycled = dbs.OpenRecordset("tblRecycled")

With rstRecycled
intRecordCount = .RecordCount
If intRecordCount <> 0 Then

.MoveFirst
.MoveLast

.MoveFirst
While Not .EOF
.Edit

snlRecUnits = ![RecUnits] - ![UsedUnits]
![RecUnits] = snlRecUnits

snlRecKG = ![RecKG] - ![UsedKG]
![RecKG] = snlRecKG

![UsedKG] = 0
![UsedUnits] = 0

.Update

intDoEvents = DoEvents()

.MoveNext


Wend

End If

Me.Refresh

rstRecycled.Close
dbs.Close

Could you please advise anything?

Thanks
 
T

Tony C

When setting a recordset, you need an extra constant: -

Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset)

If this Table is also a linked ODBC Table, then you may
need this instead: -
Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset,dbSeeChanges)

To set your record count, you need to move to the last
record in the Record Set before performing RecordCount: -

With rstRecycled
.MoveLast
intRecordCount = .RecordCount
If intRecordCount <> 0 Then


Finally, "Refresh" doesn't always work, try "repaint"
instead, replace Me.Refresh with Me.Repaint

Hope some of this helps


Tony C
 
A

Alex

Thanks a lot, Tony.
But, the result is the same - the last entry on a form
isn't working. If I go to the next row on the form it's
working. So, I need to include some code to go to the next
row on the form. Could you advise anything?

Alex
-----Original Message-----
When setting a recordset, you need an extra constant: -

Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset)

If this Table is also a linked ODBC Table, then you may
need this instead: -
Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset,dbSeeChanges)

To set your record count, you need to move to the last
record in the Record Set before performing RecordCount: -

With rstRecycled
.MoveLast
intRecordCount = .RecordCount
If intRecordCount <> 0 Then


Finally, "Refresh" doesn't always work, try "repaint"
instead, replace Me.Refresh with Me.Repaint

Hope some of this helps


Tony C
-----Original Message-----
Hi guys,

The last entries in [UsedUnits] and [UsedKG] (and
[RecUnits] and [RecKG]) are not being updated in a table
and form. I'm using a continuous form.

Set dbs = CurrentDb

Set rstRecycled = dbs.OpenRecordset("tblRecycled")

With rstRecycled
intRecordCount = .RecordCount
If intRecordCount <> 0 Then

.MoveFirst
.MoveLast

.MoveFirst
While Not .EOF
.Edit

snlRecUnits = ![RecUnits] - ![UsedUnits]
![RecUnits] = snlRecUnits

snlRecKG = ![RecKG] - ![UsedKG]
![RecKG] = snlRecKG

![UsedKG] = 0
![UsedUnits] = 0

.Update

intDoEvents = DoEvents()

.MoveNext


Wend

End If

Me.Refresh

rstRecycled.Close
dbs.Close

Could you please advise anything?

Thanks
.
.
 
A

Alex

It looks like I've resolved it. I've applied RunCommand
acCmdSaveRecord.

Thanks,

Alex
-----Original Message-----
Thanks a lot, Tony.
But, the result is the same - the last entry on a form
isn't working. If I go to the next row on the form it's
working. So, I need to include some code to go to the next
row on the form. Could you advise anything?

Alex
-----Original Message-----
When setting a recordset, you need an extra constant: -

Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset)

If this Table is also a linked ODBC Table, then you may
need this instead: -
Set rstRecycled = dbs.OpenRecordset
("tblRecycled",dbOpenDynaset,dbSeeChanges)

To set your record count, you need to move to the last
record in the Record Set before performing RecordCount: -

With rstRecycled
.MoveLast
intRecordCount = .RecordCount
If intRecordCount <> 0 Then


Finally, "Refresh" doesn't always work, try "repaint"
instead, replace Me.Refresh with Me.Repaint

Hope some of this helps


Tony C
-----Original Message-----
Hi guys,

The last entries in [UsedUnits] and [UsedKG] (and
[RecUnits] and [RecKG]) are not being updated in a table
and form. I'm using a continuous form.

Set dbs = CurrentDb

Set rstRecycled = dbs.OpenRecordset("tblRecycled")

With rstRecycled
intRecordCount = .RecordCount
If intRecordCount <> 0 Then

.MoveFirst
.MoveLast

.MoveFirst
While Not .EOF
.Edit

snlRecUnits = ![RecUnits] - ![UsedUnits]
![RecUnits] = snlRecUnits

snlRecKG = ![RecKG] - ![UsedKG]
![RecKG] = snlRecKG

![UsedKG] = 0
![UsedUnits] = 0

.Update

intDoEvents = DoEvents()

.MoveNext


Wend

End If

Me.Refresh

rstRecycled.Close
dbs.Close

Could you please advise anything?

Thanks
.
.
.
 

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

Top