Option Group Function

J

jrmfzf

I've created a function that first checks to make sure if a form is
open and then if the form is open returns the value of an option group
on the form. The function is run in a crosstab query which uses the
returned value to filter. However, when the function is run I get a
runtime error 2427, "You entered an expression that has no value" on
the arrowed line below:

Function BusOption() As Integer

Dim stDocName As String

stDocName = "VT_USAGE_FORM"
If IsLoaded(stDocName) = -1 Then 'Form is open
-> BusOption = Forms(stDocName)!BUS_SELECT 'Option group
Else
BusOption = 1 'Forms is closed
End If

End Function

I think the problem is that for some reason the IsLoaded function is
claiming that the form is open before it has actually been opened.
Here's that function:

Function IsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
IsLoaded = True
End If
End If
End Function

Does anyone have any suggestion?
 
J

jleckrone

I don't think you can code your arrowed line like that. Try changing
it to BusOption = Forms!VT_USAGE_FORM!BUS_SELECT 'Option group
 
J

jrmfzf

I'm pretty sure that's not the problem because I've coded in the same
way in other places and it worked fine. Actually, I've have already
tried changing it to the way you suggested just to double check myself
with no luck. Thanks anyways though.
 

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