How do i close and refresh a form using VBA?
Code:Forms("Adviser Records").RefreshThese are the codes I'm using. No errors pop up. It just doesn't work. The other parts of the code still work.Code:DoCmd.Close acForm, "New Adviser"
How do i close and refresh a form using VBA?
Code:Forms("Adviser Records").RefreshThese are the codes I'm using. No errors pop up. It just doesn't work. The other parts of the code still work.Code:DoCmd.Close acForm, "New Adviser"
is this behind the actual form?
and why are you refreshing it before the close? that is irrelevant, because a form saves itself automatically
I have two forms. Form 1 will display the contents of the table (Split Form) while Form 2 is where data for the table is entered. So when Form 2 closes, it will refresh Form 1.
I also have a Delete button in Form 1. When an entry is deleted, #Deleted is shown in the datasheet part of the form
first of all, "refresh" is different than 'repaint' and 'requery'. how different, i don't know. I believe refresh will get rid of those delete symbols, but not 100% sure. try them all.I have two forms. Form 1 will display the contents of the table (Split Form) while Form 2 is where data for the table is entered. So when Form 2 closes, it will refresh Form 1.
I also have a Delete button in Form 1. When an entry is deleted, #Deleted is shown in the datasheet part of the form
When you close form2, open form1 it will requery form1 for you.
And the reverse can be done, so they query each other.
Use the forms close event.
Code:Private Sub Form_Close() DoCmd.OpenForm "frmName", acNormal End Sub
FYI, Refresh does *not* get a new RecordSet so the *deleted* records are still there. It would need to be Requeried to take care of that. Refresh will get any *new* data in existing fields in the current RecordSet. Blaster's suggestion is a good one.
You got it sir! Hey Allen, is code always needed to go back to the same record you were on after a requery? doesn't a requery always take you back to rec 1?
just wanted to ask a guru. I've got code for it, but never explored the difference between the 3 methods I don't think.
Thanks guys, Appreciate the help
You're very welcome.