473,804 Members | 3,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.RunComman d 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 3087
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.RunComman d 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.RunComman d 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.RunComman d 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.RunComman d 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.RunComman d 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.RunComman d 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
2499
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 doing is saving the local file as a backup. Then I have to edit the backup, deleting the create file info and all previously uploaded entries before I can import the text file to the server. Is there an easier way to do this so I won't get...
2
8036
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 needs to be updated when certain changes are made in the parent windows form application. I've tried setting up a method in the dialog that can be called by the parent that changes/updates the text box and I've tested it to make sure the statement...
3
13091
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 running at once will there be problems with data updates? The reason I ask is I'm thinking like this: User1 launches the app and the dataset is created from the data in the DB.
7
2254
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 { private System.Windows.Forms.TextBox textBox7; ...... private void InitializeComponent()
4
2028
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 datagrid isn't going to work). On this page, people can update a variet of records. On submit, I want to then go in and update all of the records. Normally, I'd make each form element include a runat: server and then declare it in my codebhind so I...
10
5826
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: WebForm1.aspx ChangeValue.aspx WebUserControl1.ascx Module1.vb
2
1305
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: http://media.wiley.com/product_ancillary/23/07645599/DOWNLOAD/559923_CODE_8_10_16_22_23_24_25.zip \Chapter 16\AuthorEditor Basically when I have made a change and save it, close and reopen the program the changes that I made have gone, and it’s the...
4
3488
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 Y" is Private Sub Form_Current() Dim frm As Form, LastRec As Long Set frm = Forms!ReviewSearchRecordsForm
2
3324
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 CurrentChanged event of the BindingSource of the combobox to update the textbox. When selecting an item in the combobox or when selecting a row in the grid, it is updating the textbox correctly. The problem is when I apply a filter in the grid, and then...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.