By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

Updating form1 when changes are made to form 2

P: n/a
Hi All,

I have a grid (i.e. continuous form) on Form1, that opens a second form
(not a subform) Form2 when the user double clicks on it. On form2 the
user can save information. When the user selects Save, I want to
reload Form1 because the changes in Form2 will change the order that
records should appear on Form1. I have implemented this functionality
as follows:

Private Sub cmdSave_Click()
If validData Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, "Form1"
DoCmd.OpenForm "Form1"
Me.SetFocus
End If
End Sub

cmdSave is on Form2. The code above causes the forms to change
position on the task bar which I would like to avoid. Also, I think
it's just a bit rubbish. Can anyone suggest a better way to get Form1
to reload when save is selected on Form2?

All help appreciated as Access is currently a complete mystery to me.

Thanks

MM

Aug 22 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
just requery the form and it'll refresh itself from the data in the
table.

Instead of:

Private Sub cmdSave_Click()
If validData Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, "Form1"
DoCmd.OpenForm "Form1"
Me.SetFocus
End If
End Sub
use

Private Sub cmdSave_Click()
If validData Then
Me.Requery
End If
End Sub

Aug 22 '06 #2

P: n/a
Not sure if this is exactly right, but I would do something like this
(air code):

Private Sub cmdSave_Click()
dim frm1 as form
If validData Then
DoCmd.RunCommand acCmdSaveRecord
Set frm1 = "Form1"
frm1.Requery
End If
Set frm1 = Nothing
End Sub

You might also try:

Private Sub cmdSave_Click()
If validData Then
DoCmd.RunCommand acCmdSaveRecord
docmd.Requery "Form1"
End If
End Sub

I've had some trouble with the docmd.Requery not always working...

Aug 23 '06 #3

P: n/a
Hey,

The following code does the trick:
If validData Then
Dim frmTemp As Form

DoCmd.RunCommand acCmdSaveRecord
Set frmTemp = Forms("Form1")
frmTemp.Requery

Set frmTemp = Nothing
End If

Thanks for the feedback.

MM
Jim M wrote:
Not sure if this is exactly right, but I would do something like this
(air code):

Private Sub cmdSave_Click()
dim frm1 as form
If validData Then
DoCmd.RunCommand acCmdSaveRecord
Set frm1 = "Form1"
frm1.Requery
End If
Set frm1 = Nothing
End Sub

You might also try:

Private Sub cmdSave_Click()
If validData Then
DoCmd.RunCommand acCmdSaveRecord
docmd.Requery "Form1"
End If
End Sub

I've had some trouble with the docmd.Requery not always working...
Aug 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.