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

reference a sub - subform control

P: 30
I have a Main Form (Itineraries) which has a Command Button (Command11) . On the main fom I also have a sub form (ItineraryDetails). Now for every Itinerary details record there is sub sub form (ItineraryAccomodation) that I want to refer to. Would you be able to help me out I have attached an image of how the form is structured.

Below is the sample code I have tried to create.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2. On Error GoTo Err_Command11_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "ItineraryAccomodation"
  8.  
  9.     stLinkCriteria = "Me.ItineraryDetails.Form.[ItineraryDetailID]=" & Itineraries.ItineraryDetails.ItineraryAccomodation.Form.[ItineraryDetailID]
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  11.  
  12. Exit_Command11_Click:
  13.     Exit Sub
  14.  
  15. Err_Command11_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command11_Click
  18.  
  19. End Sub
Attached Images
File Type: jpg datamodel2.jpg (11.3 KB, 239 views)
Jun 2 '09 #1
Share this Question
Share on Google+
9 Replies


ADezii
Expert 5K+
P: 8,679
@xraive
I cannot make heads or tails of the Thumbnail Image, but I can show you the Syntax for referring to a Control on a Sub-Sub Form. Hopefully, this will point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Forms![Main Form Name]![Sub-Form Name].Form![Sub-Sub Form Name].Form![Control Name]
Jun 2 '09 #2

P: 30
Here is what i want to do. put a button on a main form that will open up a sub form of a record that is sub form to the main form.

I have Itinerary Form
ItineraryDetails
ItinerarayAccomodations

I would like to open the ItineraryAccomodations form which related to the itineraryDetails from from the Itinerary form
Jun 2 '09 #3

NeoPa
Expert Mod 15k+
P: 31,709
This is how to refer to items on a subform - Referring to Items on a Sub-Form.

Frankly, your question and response seem to indicate that you want us to do it for you. This is not how things work here. You're welcome to ask technical questions about how to do things, but few if any of us take kindly to requests for simple solutions.
Jun 2 '09 #4

P: 30
This is not what I intended but here is the code that I was working on.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2. On Error GoTo Err_Command11_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "ItineraryAccomodation"
  8.  
  9.     stLinkCriteria = "Me.ItineraryDetails.Form.[ItineraryDetailID]=" & Forms.[Itineraries].[ItineraryDetails].Form.[ItineraryAccomodation].Form.[ItineraryDetailID]
  10.  
  11.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_Command11_Click:
  14.     Exit Sub
  15.  
  16. Err_Command11_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_Command11_Click
Jun 2 '09 #5

NeoPa
Expert Mod 15k+
P: 31,709
Xraive, you say you have three levels of form, and you give the names of these which is useful.

Unfortunately you give different names in two of your posts so we don't really know what the names are.

The important thing that's missing though is that you don't say what you want help to achieve. This is why the answers you have so far received have been quite general.

To help you more we need accurate information of what you have, and a question that explains what you are trying to achieve.

I'm sure with these available one or more of us will be happy to help you further.
Jun 3 '09 #6

P: 30
Now what I am trying to do NeoPa si:

I have a Main Form (Itineraries)
Sub Form (ItineraryDetails)
Sub Form (ItinerarayAccomodations)


I also have a button that is located on the Main Form.

now when a single record is selected on the sub form (ItineraryDetails) i want press the buttton on the Main Form (Itineraries) and it will open up the accomodations form (ItinerarayAccomodations) for that specific record. I tried to write an event procedure to do this and it is not working.
Jun 3 '09 #7

NeoPa
Expert Mod 15k+
P: 31,709
Well, you still have a problem where the names of the items are not consistent across what you are posting. If you want help then you'd better get that sorted out first.

I made this point in my earlier post but you seem to have ignored it or not understood it correctly. Let me see if I can help you find that problem.

Look at the names you've posted and the code that you've tried and then say what the names actually are - as they do not match. I have no way of telling except from what you post - and that is still contradictory.
Jun 4 '09 #8

P: 30
sorry about that..

these are the names of the forms

Main - Itineraries
Sub - ItineraryDetails
Sub - ItineraryAccomodation

I have a button on the main form that I would like to open the ItineraryAccomodation form for each record in ItineraryDetails that I select.

below is the code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2. On Error GoTo Err_Command11_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "ItineraryAccomodation"
  8.  
  9.     stLinkCriteria = "Me.ItineraryDetails.Form.[ItineraryDetailID]=" & Forms.[Itineraries].[ItineraryDetails].Form.[ItineraryAccomodation].Form.[ItineraryDetailID]
  10.  
  11.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_Command11_Click:
  14.     Exit Sub
  15.  
  16. Err_Command11_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_Command11_Click
  19.  
  20. End Sub
Jun 4 '09 #9

NeoPa
Expert Mod 15k+
P: 31,709
Right, the details look fine now :)

Unfortunately, at 02:53 in the morning I cannot do much just now, but I will look again tomorrow as soon as I'm able.

What I notice that looks strange though (you may want to look at before I can do more) is that you are using DoCmd.OpenForm on ItineraryAccomodation. This is supposed to be a sub-sub-form (which wouldn't be opened like this). What is going on here? Is this a misunderstanding ?
Jun 4 '09 #10

Post your reply

Sign in to post your reply or Sign up for a free account.