SubForm/ Default Record focus query

GUIDO22

Registered User.
Local time
Today, 11:36
Joined
Nov 2, 2003
Messages
515
I have a form with child/subform - when the form loads any child records are also loaded by virtue of the filter criteria I have stipulated for the parent form.

Simply put, the sub-form (in datasheet view only), is a summary view of 'child' records that exist for this parent. Clicking on the summary/child record should populate the corresponding controls in the parent form.

However, the cursor in the child form (child form view is in 'datasheet' view only) defaults to the top item. If I try to select this child record in order to populate the parent form controls, nothing happens. The only way around this is to select another child record (forcing focus from the default child record) and then click back again..... if there is only one child record - you are stuck and cannot populate the controls with this records data at all.

Does anyone have any ideas how to get out of this situation please?

Thank you, all!:)
 
Clicking on the summary/child record should populate the corresponding controls in the parent form.
This seems flawed to me. Maybe this is in fact how your form operates but it is generally simpler to have the degree of detail increase as you descend the hierarchy of objects; to 'drill down' as it were.
That said, you can handle subform events on the parent form by creating a WithEvents variable and handling its events. If you want the parent form to handle the Current event of a subform you can use code like ...
Code:
private withevents m_sfm as form

private sub form_load()
[COLOR="Green"]  'set a with events reference to the form in the subform control[/COLOR]
  set m_sfm = me.mysubform.form
end sub

private sub m_sfm_current()
[COLOR="Green"]  'handle the child form current event on this form[/COLOR]
  msgbox "current event on subform: " & m_sfm.somecontrol
end sub
and the subform must have a current event handler, even if it contains no code ...
Code:
private sub form_current()
[COLOR="Green"]  'do not delete -- fires current event on parent[/COLOR]
end sub
 
'Flawed'? - Perhaps but the concept is that of an INSPECTION record in an engineering machine shop. Consider a machined part made to a contract. This machined part is inspected and there are 1...n errors in accordance with the drawing to which this part has been made.

The design I have outlined works very well and the analogyof a parent inspection and child 'error' records is easily comprehended by the member of staff who will be using the tool for recording his day to day work.

Thanks for the event handler code - I incorporated the changes suggested but the event would not fire.....

It could be due to the fact that I had disabled the subforms ability to create new records... I jhave reinstated this property and I am able to move from the single child record to the 'new' record and back in order to refresh the record.... (perhaps not ideal but it works)
 

Users who are viewing this thread

Back
Top Bottom