Problem checking if form is open

M

Max Moor

Hi All,

I have a function to test if a form is open or not. I didn't write it,
nor do I know where it came from. The function is (with the error handler
removed):

Public Function FormIsLoaded(ByVal strFormName As String) As Boolean
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
FormIsLoaded = True
End If
End If
End Function

I call this to see if a form "frmLeftNav" is open. I know for a fact
that it is not open.

SysCmd(acSysCmdGetObjectState, acForm, strFormName) returns a 1,
though, saying it is open. Of course, the Forms(strFormName).CurrentView
part then throws an error, because the form isn't open.

Does anyone understand the acSysCmdGetObjectState well enough to tell
me what might be wrong?

Regards,
Max
 
A

Allen Browne

Iterate through the Forms collection to see what's really open, e.g.:
? Forms.Count
? Forms(0).Name
and so on.

If the database is in an inconsistent state, a compact/repair may help. If
you need more than that, see:
Recovery sequence - Standard steps to recover a database
at:
http://allenbrowne.com/recover.html
The SaveAsText would be worthwhile if the previous steps don't do it.

The best way to test if a form is open any version from A2000 on is:
? CurrentProject.AllForms(strFormName).IsLoaded

Let us know if you are still stuck.
 
M

Max Moor

CurrentProject.AllForms(strFormName).IsLoaded

Hi Allen,

A compact and repair did fix the problem. Nonetheless, I've updated my
FormIsLoaded and ReportIsLoaded functions to call the AllForms or AllReports
collections, as you selected.

I've said it before, though I've lost count with you... Thank you for
the help!

Regards,
Max
 

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

Similar Threads


Top