how update form, not just table?

G

Guest

Thanks for any help.
I have some VB running off a button on a form, that gets some info from a
bond yield service, that I want add as a new record to the table.
The code correctly adds the values to the table, but the form that has the
button on it doesn't change at all (the record that I am looking at). (I
guess that's normal). If I hit the VCR one forward button, the form will just
show blank cells. It won't show the newly entered record, even though I can
check it is there by closing the form, and looking at the table. Could
someone please tell me the function that will move the current record being
looked at by the form to the newly added record?
Here's my code:
Dim MyDB As Database, MyTable As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDB.OpenRecordset("DLY_FINL", dbOpenTable)
....
With MyTable
.AddNew
![Date] = dteQueryDate
.Update
End with
Just to describe the problem one more time: If I close the form, then look
at the table, the newly entered data is there, but even if I hit the VCR one
forward button on the bottom of the form after running the macro, the newly
entered record is not there (it will just show blank cells). I have to close
the form and look at the table. If I then open the form, and go to the last
record, it will show that new record.
What I am trying to do is take bond yields off of the service, then put them
in the table. When I open the form, it will show the day before yesterday's
yields. When I run the macro, it will now show yesterday's yields.
Thanks again.
 
M

Marshall Barton

Ian said:
Thanks for any help.
I have some VB running off a button on a form, that gets some info from a
bond yield service, that I want add as a new record to the table.
The code correctly adds the values to the table, but the form that has the
button on it doesn't change at all (the record that I am looking at). (I
guess that's normal). If I hit the VCR one forward button, the form will just
show blank cells. It won't show the newly entered record, even though I can
check it is there by closing the form, and looking at the table. Could
someone please tell me the function that will move the current record being
looked at by the form to the newly added record?
Here's my code:
Dim MyDB As Database, MyTable As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDB.OpenRecordset("DLY_FINL", dbOpenTable)
...
With MyTable
.AddNew
![Date] = dteQueryDate
.Update
End with
Just to describe the problem one more time: If I close the form, then look
at the table, the newly entered data is there, but even if I hit the VCR one
forward button on the bottom of the form after running the macro, the newly
entered record is not there (it will just show blank cells). I have to close
the form and look at the table. If I then open the form, and go to the last
record, it will show that new record.
What I am trying to do is take bond yields off of the service, then put them
in the table. When I open the form, it will show the day before yesterday's
yields. When I run the macro, it will now show yesterday's yields.


I think you need to requery (or Refresh) the form to get the
new data.

But, there's probably an easier way. Instead of adding the
data to the table, let's try adding it to the form's
recordset:

With Me.RecordsetClone
.AddNew
![Date] = dteQueryDate
.Update
Me.Bookmark = .LastModified
End with
 

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