Solved

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

Posted on 2010-09-22
7
1,302 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now