Visual Basic/Access

Advertisement


Question
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.

Jim

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 mgravi@yahoo.com in zipped format.

---------- FOLLOW-UP ----------

QUESTION: Ravindra
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.

Jim

Answer
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 mgravi@yahoo.com.

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ravindra

Expertise

visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6) basic questions in vb 2008. Optional: 1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a good amount. 4) you can visit my website http://ravindra.coolpage.biz

Experience

programming since the past 15 years. have completed a large number of projects in Industrial applications, finance,accounts, correspondence. excel macros etc

Education/Credentials
engineering, management degrees.

Past/Present Clients
project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb

©2016 About.com. All rights reserved.