Problem with unloading a loaded form in vba

J

Jack

Hi,
I have loaded a form that I need to unload after an operation. However in
the process of unloading it I am getting compile error (type mismatch) I have
the following code which is not working. I appreciate any help for
resolution. thanks

CODE
Dim DocName As String
DocName = "frmCompositeSearch"

If Not IsLoaded(DocName) Then

'Do something
Else
'Do something else
Unload (DocName) ----- THIS LINE IS GIVING ME THE ERROR MESSAGE
End If
 
M

Marshall Barton

Jack said:
I have loaded a form that I need to unload after an operation. However in
the process of unloading it I am getting compile error (type mismatch) I have
the following code which is not working. I appreciate any help for
resolution. thanks

CODE
Dim DocName As String
DocName = "frmCompositeSearch"

If Not IsLoaded(DocName) Then

'Do something
Else
'Do something else
Unload (DocName) ----- THIS LINE IS GIVING ME THE ERROR MESSAGE
End If


Access doesn't have an Unload statement (or, for that
matter, a Load statement). If you opened the form using the
OpenForm method, then try using:

DoCmd.Close acForm, DocName, acSaveNo
 
J

JimBurke via AccessMonster.com

Like Marshall said, there's no IsLoaded or Unload Access functions. I'm
guessing you may have copied some code from somewhere, and the person whose
code you copied had created routines called Isloaded and Unload. Like
Marshall said, the Unload function probably just closed the form. The
IsLoaded function more than likely just did something like this:

If CurrentProject.AllForms(docName).IsLoaded Then
IsLoaded = True
Else
IsLoaded = False
End If
 
J

John W. Vinson

Hi,
I have loaded a form that I need to unload after an operation. However in
the process of unloading it I am getting compile error (type mismatch) I have
the following code which is not working. I appreciate any help for
resolution. thanks

CODE
Dim DocName As String
DocName = "frmCompositeSearch"

If Not IsLoaded(DocName) Then

'Do something
Else
'Do something else
Unload (DocName) ----- THIS LINE IS GIVING ME THE ERROR MESSAGE
End If

Try

DoCmd.Close acDataForm, DocName
 
J

Jack

Thanks Marsh for your help. I appreciate it.

Marshall Barton said:
Access doesn't have an Unload statement (or, for that
matter, a Load statement). If you opened the form using the
OpenForm method, then try using:

DoCmd.Close acForm, DocName, acSaveNo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top