Refreshing...

  • Thread starter Thread starter Ryan
  • Start date Start date
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
 
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.
 
Back
Top