473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Updating form1 when changes are made to form 2

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
3 3063
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paige | last post by:
I have a database on my local machine that I make entries and corrections on. I'd like to be able to upload that to my server and have that update the database that's on the server. What I've been...
2
by: Dennis C. Drumm | last post by:
I have a window form dialog that I use in a non modal fashion. It is displayed using Show() in stead of ShowDialog() from the parent windows form application. I have TextBoxes in that dialog that...
3
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be...
7
by: trint | last post by:
I have a textbox (textBox7) that isn't updating.. Is there a way, after I type new text in it, to have it update? It seems to be fairly normal: public class Form1 : System.Windows.Forms.Form {...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
2
by: Commander Ace | last post by:
Hi, I'm having some problems with updating an SQL Database with modified fields from a datatable. I got the code from a Wrox book, 'Professional VB.NET 2003', the same code can be found here:...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.