Hi Francisco,
I think there's a good chance I don't understand the problem, but how about this...
Code:
Function GetValue(ControlName As String, DefaultValue As Variant)
If IsOpen(Forms("MyFormName").Name) Then
GetValue = Forms("MyFormName").Controls(ControlName)
Else
GetValue = DefaultValue
End If
End Function
Function IsOpen(FormName As String, Optional intObjectType As Integer = acForm)
'Access 97
IsOpen = (SysCmd(acSysCmdGetObjectState, intObjectType, FormName) <> 0)
'Access 2000 and up
IsOpen = currentproject.allforms(FormName).IsLoaded
End Function
Then put
=GetValue("cboCompanyName","Microsoft")
or whatever into your query