Opening and editing as tabbed subform

edh

Registered User.
Local time
Today, 00:15
Joined
Aug 29, 2012
Messages
11
Hi there, I am building a database which has UI with a main booking form and the sub forms for the fine details, I have the sub forms on tabs and have a check box make the tabs visible when it is checked. I have set the sub form to take the parent form's Ref no through a lookup but when I tab over the Subform is stuck on the record it was on last time I opened it and another instance of the subform has opened behind the the (popup) window containing the form. here's my code:

Private Sub chkEvent_AfterUpdate()


If Me![chkEvent] = True Then
[Event 1].Visible = True
'Next line is where I think the problem might be
DoCmd.OpenForm "BookEvent1", acNormal, , , acFormAdd
Forms![BookEvent1]![ParentBooking].Value = [OrderID]
Else
'Next set of procedures not complete, gonna have it delete the record if the box is unchecked'
If (MsgBox("Cancel all events for this booking? this operation cannot be undone", vbOKCancel) = vbOK) Then
[Event 1].Visible = False
Else
Me![chkEvent] = True
End If
End If
End Sub

I think the problem is in the DoCmd.OpenForm "BookEvent1"... line. I assume i need to refer to the "BookEvent1" form through a path that includes the parent form ("BookingForm")

One other detail, I don't want to fix this with an "on open moveTo" jobbie if it means that if I make a new record for that subform it automatically jumps past the sub-booking record that belongs to the main booking's record. I'd like to correct within this Sub if possible

Hopefully I haven't jumbled up my explanation beyond understanding.
Hope you can help.


EDIT -

Thought I should add, The "BookEvents1"form isn't actually a subform I created it separately from the main form and it is grouped with it's own recordset. Thanks.
 
Last edited:
I have set the sub form to take the parent form's Ref no through a lookup but when I tab over the Subform is stuck on the record it was on last time I opened it and another instance of the subform has opened behind the the (popup) window containing the form.
So why are you not linking your subform to the parent form via the Link Master Fields and Link Child Fields properties? Or do you think it's not possible because the subform sits in a Tab control?
 
Thanks for taking the time to get back to me. In answer to your question: a) I originally set it up with a different structure and b)I want to be able to view all events independently of the main form and as I intend to have multiple BookEvents tabs on this form in case of one booking having 3-4 events within it, therefore I want the "BookEvents1,2,3,4,5" forms all feeding into the database, "BookEvents". c) I am in no way an expert at this. Maybe I should be making the "BookEvents" Forms Child forms and using a query to view all together, I don't know (It would be nice to be able to edit from the table view...) Is that going to solve my problems here? is it going to effect the lookup I have for getting the ;parent form's BookingNo to the child? I have that look up bringing over the customer's name and contact details at the moment? If you could tell me what to do to change that property correctly in this situation (assuming it's the right thing to do) that'd be great.

Thanks, Ed.
 
The main form is what drives the subform so having a link between the parent and the child means when you move from one record to the other from the parent form, the child filters its records to only reflect those that match with its parent. With the property set moving between records in the child form will not affect the parent form, but like already mentioned it's the parent that drives the child, not the other way round.

Drop a new subform onto your parent form, use the wizard and you will get to a point where it asks you to select the linkage fields. Select the appropriate fields and continue till the end. Now open your parent form, move between records and watch the child form change as well. Look at the property of the subform control to see how the Link Master Fields and Link Child Fields properties are set.
 
Thanks very much, for the advice. got that pegged now.
 

Users who are viewing this thread

Back
Top Bottom