Isloaded...........

taicho

Registered Abuser
Local time
Yesterday, 23:41
Joined
Dec 13, 2005
Messages
24
Hello my brother and sisters! I am need of your help once again. Anybody got the fuzzy warbles to help me out??

Ok so here is the problem, I have a form in which customers can be edited and it is meant to only be opened from another form because when it closes the customerID is passed on to the other form. Now the problem is that if the database is closed with that window open or the customers form is closed without the other form open to pass the value on to I of course get an error, my question is then how can I use the IsLoaded property to say for instance if Form "Main" is not open then do not try to pass value i.e. If A IsNull then don't do anything...?

P.s. I've checked the forums and tried the little snippets I've found but I just can't figure it out...
 
If IsLoaded("YourForm") Then

DoSomething

Else

DoSomethingElse

EndIf
 
If you have ac2K+ you could also pass the information in the OpenArgs argument of the OpenForm command and not have to deal with the error or referencing a form through the Forms collection.
 
Could you describe what you mean with an example RuralGuy? :-) By the way Rich I tried that and I think it's they same snippet I found before but what I get is "Sub, Function, or Property not defined (Error 35)"...
 
Here is the code...

<code>
Private Sub Form_Unload(Cancel As Integer)

If IsLoaded("SalesUnFiltered") Then

Forms!SalesUnFiltered.CustomerID = Me.CODE

Else

MsgBox "HEY!!"

End If


End Sub
</code>

and that is what still gives me an "Sub, Function, or Property not defined (Error 35)"
 
Put this in a standard module named basFunctions.
Code:
Public Function IsLoaded(ByVal strFormName As String) As Boolean
 ' Returns True if the specified form is open in Form view or Datasheet view.
    
    Const conObjStateClosed = 0
    Const conDesignView = 0
    
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
        If Forms(strFormName).CurrentView <> conDesignView Then
            IsLoaded = True
        End If
    End If
    
End Function
 
Forms!SalesUnFiltered.CustomerID = Me.CODE, I know using this technique is frowned upon but I didn't know what else to use and it works just that I need this IsLoaded to work with it so my users don't see a VB error...
 
Problem solved! RuralGuy you are truly a master, thank you very much for your help it is much appreaciated :-D P
 
Glad I could help but some day you need to learn about OpenArgs.
 

Users who are viewing this thread

Back
Top Bottom