Avatar of beatified
beatifiedFlag for United States of America asked on

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.

Thanks,
Stuart
HCPV-Current.accdb
New-Tenant-Button.jpg
Make-Select-Error.jpg
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
PatHartman

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

Forms!mainform!subform!control
ASKER CERTIFIED SOLUTION
Fabrice Lambert

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
beatified

Thank you both for the answers.
@PatHartman
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.
HCPV-Current.accdb
PatHartman

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-

Resume

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
beatified

@PatHartman
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.
PatHartman

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.