Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-22
7
Medium Priority
?
1,399 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 500 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

972 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