Form does not go back to calling form

M

martybr

Good morning..

I have a database that has 3 forms, FormA, FormB, and FormC.

The reason there are 3 forms are:

1. FormA is the 'Main' form. It contains all the tasks that need to be
completed. It has a button that calls FormC

2. FormB is a filtered version of FormB. It contains all the
'Marketing' tasks to be completed.It also has the button that calls
FormC

3. FormC is a subtask list. It contains subtask from either FormA or
FormB. It has a 'back' button to go back the form that called it.

Here is the issue:
FormC's button does not go back to the form that called it. It goes
back to the form that orginally called it when the form was first
opened.

Behavior:
When the database is opened and FormA called FormC, FormC will go back
to FormA. Fine. When FormB calls FormC, FormC will still go back to
FormA, not FormB. Not fine.
When I close and reopen the database, and FormB will call FormC first,
FormC would now always go back to FormB. Not fine


Here is the code in the buttons:
1. FormA and FormB has the following syntax when They call FormC from
the button "DoCmd.OpenForm stDocName, , , Me![ItemNo], , , Me.Name"

2. FormC has the following syntax when calling the 'parent' form which
can be either FormA or FormB
"DoCmd.OpenForm Me.OpenArgs, , , stLinkCriteria"

How do I need to reset the OpenArgs to null after it is opened?

Any ideas?

Thank you.
 
D

Douglas J. Steele

The OpenArgs property is read-only, and hence cannot be reset to Null or any
other value.

It sounds as though in case 1, you're not actually opening FormC from FormB:
you're reactivating the version of FormC that was opened from FormA. You'll
either need to check whether FormC is already open before you try to open
it, or else store the value from OpenArgs in a text box on the form (it
doesn't have to be open), and reset the value whenever you do a "re-open"
 
M

martybr

Thank for your responses.

In FormC, I added this line to save and close FormC

DoCmd.OpenForm Me.OpenArgs, , , stLinkCriteria
--> DoCmd.Close acForm, "frmSubOpenItems", acSaveYes

It now goes back to the form that opened it.

Now to the next challenge..
 
T

Tom Wickerath

Hi Marty,

You shouldn't need the optional acSaveYes argument. And you can make this
code a bit more generic (thus easier to copy from one form to another) by
doing this:

DoCmd.Close acForm, Me.Name

If this is a bound form, you should force a save operation, if the record is
dirty, ie.

If Me.Dirty = True Then
Me.Dirty = False
End If

DoCmd.Close acForm, Me.Name

However, if this is an unbound form, don't attempt to test for the dirty
property, because doing so will generate a run-time error. The reason that
you want to ensure that you force a save (setting Me.Dirty = False is one way
of saving a record) with bound forms is shown in Access MVP Allen Browne's
tip, here:

Losing data when you close a form
http://allenbrowne.com/bug-01.html


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top