473,416 Members | 1,759 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,416 software developers and data experts.

help with DoCmd.Close

hi there,

I am needing some help with a database I am putting together. The database
works off of a main Form, which then has buttons on it that will open up
other forms. The problem I am having is that if I am updating any
information on the current record, and then open one of the other forms, the
new form will not show the updated information. I realize that a simple
macro solves this problem by basically closing the first form, opening the
new form, and then on exiting the new form opening the first one again. The
problem is, that with one of the sub forms that I need to open requires some
vb script with it. Here is the script:

Private Sub INDIVIDUALSLIP_Click()
On Error GoTo Err_INDIVIDUALSLIP_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmIndividualSlip"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
Exit_INDIVIDUALSLIP_Click:
Exit Sub

Err_INDIVIDUALSLIP_Click:
MsgBox Err.Description
Resume Exit_INDIVIDUALSLIP_Click
End Sub
Now, I have tried playing around with the DoCmd.Close but I just cannot seem
to get it to work. It always ends up telling me that I am refering to
something that doesn't exist or is already closed. So the help that I am
seeking is basically being able to have the script not only do what it is
currently doing, but also close the form so that the changes show when the
new forms opens up. However, I think I just had one of those "eureka"
moments. I think I see what my problem is...hehe...The main form has
specific ID values attached to each record, and when the "frmIndividualSlip"
is being called to open up, it is grabbing the ID value from the main form
(which is still open) so that it will retrieve the record that is being
looked at in the main form. Which is what I need it to do. So, now that I
realize the obstacle that I am faced with, is there any way around it? Am I
able to have the record that has been updated in the main form, still
populate itself in the new form that is being called to open, and still
contain the updated values?

I also realize that this problem can be solved by just going forward one
record, and then coming back to the record that was updated, and then
calling the new form to open it, thus showing the new values. And this is
what I have been doing, the only problem is that I know once I ask people to
use this database they may forget from time to time to do the whole "forward
then back".

I really appreciate any help that can be offered.

Thank You
Nov 13 '05 #1
2 3269
If you don't leave the current form, it doesn't get saved. Eventually it gets
saved when you close the form or return to the form and go to another record. In
your code to open the other record, do a:
DoCmd.RunCommand acSaveRecord
before opening the other form.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"chanchito_cojones" <ch**********@hotmail.com> wrote in message
news:CE*********************@twister01.bloor.is.ne t.cable.rogers.com...
hi there,

I am needing some help with a database I am putting together. The database
works off of a main Form, which then has buttons on it that will open up
other forms. The problem I am having is that if I am updating any
information on the current record, and then open one of the other forms, the
new form will not show the updated information. I realize that a simple
macro solves this problem by basically closing the first form, opening the
new form, and then on exiting the new form opening the first one again. The
problem is, that with one of the sub forms that I need to open requires some
vb script with it. Here is the script:

Private Sub INDIVIDUALSLIP_Click()
On Error GoTo Err_INDIVIDUALSLIP_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmIndividualSlip"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
Exit_INDIVIDUALSLIP_Click:
Exit Sub

Err_INDIVIDUALSLIP_Click:
MsgBox Err.Description
Resume Exit_INDIVIDUALSLIP_Click
End Sub
Now, I have tried playing around with the DoCmd.Close but I just cannot seem
to get it to work. It always ends up telling me that I am refering to
something that doesn't exist or is already closed. So the help that I am
seeking is basically being able to have the script not only do what it is
currently doing, but also close the form so that the changes show when the
new forms opens up. However, I think I just had one of those "eureka"
moments. I think I see what my problem is...hehe...The main form has
specific ID values attached to each record, and when the "frmIndividualSlip"
is being called to open up, it is grabbing the ID value from the main form
(which is still open) so that it will retrieve the record that is being
looked at in the main form. Which is what I need it to do. So, now that I
realize the obstacle that I am faced with, is there any way around it? Am I
able to have the record that has been updated in the main form, still
populate itself in the new form that is being called to open, and still
contain the updated values?

I also realize that this problem can be solved by just going forward one
record, and then coming back to the record that was updated, and then
calling the new form to open it, thus showing the new values. And this is
what I have been doing, the only problem is that I know once I ask people to
use this database they may forget from time to time to do the whole "forward
then back".

I really appreciate any help that can be offered.

Thank You

Nov 13 '05 #2
You are a godsend!!! Thank you so much.

cheers
"PC Datasheet" <no****@nospam.spam> wrote in message
news:do******************@newsread2.news.atl.earth link.net...
If you don't leave the current form, it doesn't get saved. Eventually it gets saved when you close the form or return to the form and go to another record. In your code to open the other record, do a:
DoCmd.RunCommand acSaveRecord
before opening the other form.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"chanchito_cojones" <ch**********@hotmail.com> wrote in message
news:CE*********************@twister01.bloor.is.ne t.cable.rogers.com...
hi there,

I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up
other forms. The problem I am having is that if I am updating any
information on the current record, and then open one of the other forms, the new form will not show the updated information. I realize that a simple
macro solves this problem by basically closing the first form, opening the new form, and then on exiting the new form opening the first one again. The problem is, that with one of the sub forms that I need to open requires some vb script with it. Here is the script:

Private Sub INDIVIDUALSLIP_Click()
On Error GoTo Err_INDIVIDUALSLIP_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmIndividualSlip"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SlipID.Value
Exit_INDIVIDUALSLIP_Click:
Exit Sub

Err_INDIVIDUALSLIP_Click:
MsgBox Err.Description
Resume Exit_INDIVIDUALSLIP_Click
End Sub
Now, I have tried playing around with the DoCmd.Close but I just cannot seem to get it to work. It always ends up telling me that I am refering to
something that doesn't exist or is already closed. So the help that I am seeking is basically being able to have the script not only do what it is currently doing, but also close the form so that the changes show when the new forms opens up. However, I think I just had one of those "eureka"
moments. I think I see what my problem is...hehe...The main form has
specific ID values attached to each record, and when the "frmIndividualSlip" is being called to open up, it is grabbing the ID value from the main form (which is still open) so that it will retrieve the record that is being
looked at in the main form. Which is what I need it to do. So, now that I realize the obstacle that I am faced with, is there any way around it? Am I able to have the record that has been updated in the main form, still
populate itself in the new form that is being called to open, and still
contain the updated values?

I also realize that this problem can be solved by just going forward one
record, and then coming back to the record that was updated, and then
calling the new form to open it, thus showing the new values. And this is what I have been doing, the only problem is that I know once I ask people to use this database they may forget from time to time to do the whole "forward then back".

I really appreciate any help that can be offered.

Thank You


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
4
by: Nathan Bloomfield | last post by:
I cannot figure out how to synchronize 2 replicas using VB code. I have tried many variations, and there are surprisingly few examples in the newsgroups. The synchronization is working...
2
by: bpaff | last post by:
Can anyone help me, I am trying to add a close statement to a procedure to close the current and then open the next window. I am working with command8 below. Option Compare Database Private...
0
by: Linda Cacina | last post by:
Hello all you fine folks, Here is some code I am using to merge data from a single record Access 2K3 table into a NEW word document based on a pre-defined Word merge template doc. All I want to...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
0
by: jpodesta | last post by:
Hello- I am fairly new to MS Access and would like to use some macros in .xls in an Access Module. I have tried to do this on my own but failed to make it work. I have included the xls macros...
4
by: jpodesta | last post by:
I would like to add the xls macros below to the module listed. I am looking for advice as to the best way to go about this. module Public Function clean_pn(pn_in As Variant) As String
8
by: DP | last post by:
hi, i've got a price of code, which checks to see if a film is on rent, or available. but how can i actualyl make the cancel button do somthing? because, the cursor gets stuck on the filmID...
9
by: Chris Ahmsi | last post by:
I have been tasked to create a 'simple' form in Access providing managers to input necessary changes. I have 2 command buttons on the form and a check box. Command button 1 updates my table for...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.