Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1418
  • Last Modified:

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

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
shogun5
Asked:
shogun5
  • 3
  • 2
  • 2
1 Solution
 
Farzad AkbarnejadCommented:
Use the following command:

DoCmd.Close acForm, "Welcome"

-FA
0
 
MINDSUPERBCommented:
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
 
MINDSUPERBCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MINDSUPERBCommented:
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
 
shogun5Author Commented:
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
 
Farzad AkbarnejadCommented:
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
 
shogun5Author Commented:
FarzadA,

Thank you. I understand now.

Mike
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now