Errors in Access forms and subforms.

I am getting two errors.

First one is when I click the "New Tenant" button on the bottom of the "frmNewLease"

The second is when I select a Make in the Vehicle form. This seems to work fine when I bring up the form independently but not when I bring it up as a subform.

See the attached Screenshots and DB

I am also unsure that the Vehicle form is properly connected to the Tenant which is its parent form.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To refer to a subform on a form, you must include the main form

Fabrice LambertConsultingCommented:

Concerning your first issue, instead of referencing through the top object (forms collection), why not simply:

Open in new window

Concerning your 2nd issue, you attempt to execute a query with the same name as the comboBox control. But you have none named like that.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
beatifiedAuthor Commented:
Thank you both for the answers.
I am trying to learn how to do this but don't seem to be having much luck. I even tried the subform wizard and I figured it would be sufficient. The problem is that It seems the other errors are getting in the way of checking to see if it is working.

@Fabrice Lambert
I found that I had an error in the relationships but now that it is fixed the frmVehicle form works as expected but that same form as a subform doesn't work. Any idea as to why? I know you said that I was trying to execute a query with the same name as the comboBox but wouldn't that mean that the form on its own would have the same error? Right now it doesn't.

And thanks for the requery fix it worked like a charm.

I've attached a new copy of the DB to reflect the relationship change and BTW was under tblCarModel.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

If the form works as a main form but not as a subform, you have some reference that is incorrect and you need to find it.  "doesn't work" is not helpful.  What is the error message you are getting and can you identify the line of code that is causing it?  When the error message pops up, use cntl-break to drop into the code.  If you drop into an error routine, you need to add a line of code after your module exit-


Then move the focus to the Resume statement using the yellow right arrow from the debug menu.  Click on the line you want to be active and then click on the yellow right arrow.  The line with the focus should highlight.  Then you can step through the code and focus should move to the line that actually caused the error.

As long as the Resume is after an Exit Sub or Resume Next, it will never be executed.  It is only there  for you to use for debugging.
beatifiedAuthor Commented:
I am not receiving an error at this point. I am just getting something asking for criteria for a requery. Everything seems to work fine when the the form is loaded independantly but but doesn't work when the form is a subform. The form I am referring to is frmVehicle.
There is an issue with how you are referencing the form.  As I mentioned originally, you MUST include the mainform name in front of the subform name.  Look again at my example.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.