If statement for DefaultValue

cavscout

Registered User.
Local time
Today, 15:29
Joined
Mar 13, 2003
Messages
74
I'm trying to populate a field on single form with input that could come from three different forms in my database depending on which department is using it. I keep getting a #Name? in the field instead of the job number.

In the forms OnOpen event I have:

If IsOpen("frm-SelectJobsBySearchCriteria") Then

Subject.DefaultValue = Forms![frm-SelectJobsBySearchCriteria]![QUOTE #]

ElseIf IsOpen("frm-Daves Report") Then

Subject.DefaultValue = Forms![frm-Daves Report]![QuoteString] & " "

ElseIf IsOpen("frm-Order Lookup Browse") Then

Subject.DefaultValue = Forms![frm-Order Lookup Browse]![SALES_ORDER] & " "

End If


The IsOpen function is:

Public Function IsOpen(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in form view

Const conDesignView = 0
Const conObjStateClosed = 0

IsOpen = False

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then

If Forms(strFormName).CurrentView <> conDesignView Then
IsOpen = True
End If
End If

End Function

Can anyone get me back on course? I'm doing this so I don't have to build three different forms simply to pull from three different forms.

Thanks in advance,
 
That was perfect Pat.

I'm curious to see how many forms I can weed out using this little gem.

Thanks for the fast response.
 

Users who are viewing this thread

Back
Top Bottom