Refreshing...

R

Ryan

I have a form that contains a command button which when
clicked appends information to my underlying table
connected to my form. The problem is that I can't see the
appended information unless I close the form and reopen
it. How can I refresh the form to show the added data?

Thanks,
Ryan
 
D

Dirk Goldgar

Ryan said:
I have a form that contains a command button which when
clicked appends information to my underlying table
connected to my form. The problem is that I can't see the
appended information unless I close the form and reopen
it. How can I refresh the form to show the added data?

You must requery the form. In the button's event procedure, after
adding the new record, execute the statement

Me.Requery

Note that the above statement will reposition the form at the first
record. If you want to stay on the current record, you can save the
value of its primary key field, and then reposition to that record;
e.g.,

Dim varKeyValue As Variant

varKeyValue = Me!KeyFieldName

Me.Requery

Me.Recordset.FindFirst "KeyFieldName=" & varKeyValue
' note: the above line is for a numeric field.
' minor changes are needed for text or date fields.
 

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