QUESTION: Dear Ravindra
I have an access form containing 2 subforms both of which have worked correctly and populated on opening the main form. I have since added an unbound year combo box that now works the subform by refreshing both subforms after an update.
However, I cannot now get the subforms to populate on loading the main form and they will not populate after the combox box is updated. If I go into the main form design and back to form it opens correctly and everything works.
I have requery commands for the subforms in the load event of the main form and a value command for the combo box but I cannot seemed to get the subforms to populate on load.
Could you please advise where I may be going wrong. I have limited vba skills.
ANSWER: the form load event works when the form is visible fully. so instead of this make it a function and call this function in form load.
you state that adding the combo box for the year, your queries may not be refreshed or have the wrong code. i can solve it if you send the programme to me at email@example.com in zipped format.
[an error occurred while processing this directive]---------- FOLLOW-UP ----------
I am not sure I understand what you are asking me to do in relation to the load event and making it a function. In the load event of the main form have retained the code Me.YearEP.value = Year(Now()) which works and populates the combobox [yearEP] with 2014.
Both Sub form queries criteria rely on this date and the AfterUdate event code has [Forms]![Current EP's]![CountCurrentMembersEP subform].Requery, [Forms]![Current EP's]![CurrentMembersEPbyPreceptory subform].Requery. This works fine when the subforms are populated.
My problem is that the subforms do not populate when the main form is loaded and I am having to go into design and then Form when everything is then populated.
I do not have an issue with the combobox or its codes but something appears to be preventing the subform queries from reading the [yearEP]and running to populate the subforms when the main form is loaded. I have tried adding open query codes within the main form load event but that does not work either.
Could you please explain what you mean by making a function within the load event.
which version of office are you using?
after reading your code it appears it is not proper.
to get the value you need to use comboname.text=year(now()) ' use Text and not value
this should be in the form open event.
your requery code is also wrong.
i can rectify this if you send me this access database in zipped format. to firstname.lastname@example.org.