Question : Is there a way to turn off query parameter prompts?

I would like to turn off query parameter prompts.  I use a form to filter my query, but in many cases I open the query and run it without the form, and I do not want the query to ask for the prompts.  What are my options?

Answer : Is there a way to turn off query parameter prompts?

>> "is there a way to code the parameter when it can't find the form value it uses null as opposed to the form value?"

You'd need to switch to using a function as your parameter value in this instance.
The function could accept a Form expression passed as parameters or a string formated expression (but *not* as an actual form expression of you'll encounter exactly the same behaviour as the expression service attempts to resolve it for you!)

For example - a simplistic example originally posted elsewhere.
Your query can reference the function passing the form name and control as arguments.
e.g.
SELECT * FROM TableName WHERE FieldName = fOptionalParam("MyForm", "MyControl")

I'll voice the caveat this time though lol.
If Null is returned - that will see no results returned (as your field value can never equal Null).
That's how I'd want to see it work anyway personally - but just so you know.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Function fOptionalParam(strForm As String, strControl As String) As Variant 
On Error GoTo errHere 
 
    Const cDefault = Null 'Default to return if form value not valid 
 
    fOptionalParam = cDefault 
 
    If CurrentProject.AllForms(strForm).IsLoaded Then 
        fOptionalParam = Forms(strForm).Controls(strControl).Value 
    End If 
 
    Exit Function 
 
errHere: 
    If Err = 2467 Then 
        'Invalid form reference - ignore ?
    Else 
        MsgBox "Uh oh - Error " & Err.Description 
    End If 
End Function 
Open in New Window Select All
Random Solutions  
 
programming4us programming4us