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

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