We help IT Professionals succeed at work.

Errors in Access forms and subforms.

beatified
beatified asked
on
96 Views
Last Modified: 2018-05-25
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
Comment
Watch Question

CERTIFIED EXPERT
Distinguished Expert 2017

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

Forms!mainform!subform!control
Consulting
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
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.

Author

Commented:
@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.
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.