Open Form with Specific Subform

samjh

Registered User.
Local time
Today, 22:23
Joined
Jan 10, 2013
Messages
64
Hi,

Firstly I appologise for posting another thread regarding opening a form with a spcific subform showing, however I just seem to be unable to take any of the previous answers and relate it directly to what I need.

Basically I have a database that records commitments for clients. The user can go a client form, and within that form there is a subform which shows each expenditure commitment for that person (wihtin the subform there is also another subform that shows all income attached to each commitment). The user can use the Next and Previous buttons to navigate through the expenditure commitments (and the same if they want to navigate through the income commtiments within each expenditure commitment).

If you double click on any specific commitment whithin any part of the subform, then the expenditure commitment form (or the income commitment form if it is an income one) opens to allow the user to change stuff.

My database is set up so that each time a form opens the previous form closes.

So when the user has the commitment form open and clicks close, the client form will re-open. My issue is that is always goes back to showing the very first commitment and the user then has to navigate back through till they find the one they have just updated.

What I would like to be able to do is when the user closes the commitment for that the client then the form opens up with the specific subform on the screen that they have just changed.

The code I currently have written on the Close command of the Commitment is as follows:

Code:
Dim stDocName As String
 Dim stLinkCriteria As String
 
 stDocName = "frmTotalCommitmentsbyClient"
 
 stLinkCriteria = "[FrameworkID]='" & Me![FrameworkID] & "'"
 DoCmd.OpenForm stDocName, , , stLinkCriteria
 DoCmd.Close acForm, "frmCommitments"

I essentialy just need the bit that would also say show the subform (which is called subfrmComms2) where the commitmentID = the commitment ID on the Commitment form.

Now just to really complicate matters, I would also like this to happen if someone has the Income Commtiment form open and they close it, only the Income Commitment subform is actualy a subform of subfrmComms2 (above), but equally the income commitment form has within it the Expenditure ID, the Income ID and the FrameworkID.

So I think i have all the details needed, I just don't know how to write it.

Sorry for such a long post, and I hope I have explained this fully enough. Any help would be greatly appreciated.

Thanks.
 
One option would be to hide the first form rather than close it, then make it visible when you close the second.
 
Thanks for your reply both, however I don't want to hide the main form as I had a problem with it updating with any changes plus I did have an issue with it saying I had too many databases open.

I'm pretty sure there is a way to open showing a specific sub-form I just don't know how to write it into my code.
 

Users who are viewing this thread

Back
Top Bottom