Solved

Access DoCmd.Close Run-time error '13' type mismatch

Posted on 2010-09-22
7
1,349 Views
Last Modified: 2012-05-10
Experts,

Not why I am getting this error message.

Debug highlights on   DoCmd.Close "Welcome"

Of course when I just use DoCmd.Close the form that just opened is closes.

I really just want to open the frmVisitorlog and close the Welcome forms. I even tried to reverse the two lines and I still get the same message.

How can I fix this?

Thanks!


Private Sub Command21_Click()
  DoCmd.OpenForm "frmVisitorLog"
  DoCmd.Close "Welcome"
End Sub

Open in new window

0
Comment
Question by:shogun5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 125 total points
ID: 33732370
Use the following command:

DoCmd.Close acForm, "Welcome"

-FA
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 33732779
Or, if  command button is a form "Welcome", you may use the codes below as well:

Private Sub Command21_Click()
  DoCmd.Close
  DoCmd.OpenForm "frmVisitorLog"
End Sub


Sincerely,

Ed
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 33732784
Sorry, it should be read as

Or, if  the command button is in a form "Welcome", you may use the codes below as well:
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 33732824
shogun5,

<No points needed>

FarzadA suggestion surely solves the issue. Considering that you mention about reversing the two lines, I posted here the other way. Just for information and reference purposes.

Sincerely,

Ed
0
 

Author Closing Comment

by:shogun5
ID: 33733565
FarzadA,

Yep! That was it. May I ask why this will work

DoCmd.OpenForm "formName"

but I get an error here:

DoCmd.Close "Welcome"

and much add acForm like

DoCmd.Close acForm "Welcome" ?

Thanks!
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 33733652
Hello,
DoCmd.OpenForm knows that it must open form so you need only pass form name to it. But DoCmd.Close closes more than form objects. You must pass what type of objects that you want close. Passing form name instead of object type will cause type mismatch in passing arguments to DoCms.Close method.

-FA
0
 

Author Comment

by:shogun5
ID: 33733732
FarzadA,

Thank you. I understand now.

Mike
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question