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

help with DoCmd.Close

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.