Problem with unloading a loaded form in vba

  • Thread starter Thread starter Jack
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top