Well, if you are using a form, I am going to assume that you have a command button, with a click event to run the query. You can test the value of the text box, and if it is empty, then set it to your default.
OK, on your form, do you have a button to run the query? If so, could you post the code that the button runs? I can show you how to modify it.
Also, please post the SQL for the query that you want to run. You will be using the parameter to build an SQL statement 'on the fly' and running it from code.
SQL:
SELECT span_ip_cl_acc_hold_trans.cl_number
FROM ...
WHERE ((span_ip_cl_acc_hold_trans.cl_number) Between [Forms]![SwitchConfLInputParams]![txtClientNumberFrom] And [Forms]![SwitchConfLInputParams]![txtClientNumberTo]) And ((span_ip_cl_acc_hold_trans.proc_date)=[Forms]![SwitchConfLInputParams]![txtProcessedDate]));
Sorry, but I have one more question. Your button opens the query, which is unusual. Usually, one would open a form or report based on the query. Are your users editing the query directly?
Anyway, here is the modified code. This is not exact;
Private Sub cmdOpen_Click()
On Error GoTo Err_cmdOpen_Click
Dim stDocName As String
Dim strSQL as string
Dim strNumFrom as string
Dim strNumTo as string
Dim datProcDate as date
Dim qdf as QueryDef
'SET UP YOUR DEFAULT VALUES
If me![txtClientNumberFrom] ="" then
strNumFrom= YourDefaultValue
else
strNumFrom = me![txtClientNumberFrom]
end if
'SAME LOGIC FOR THE OTHER TWO PARAMETERS.
strSQL = "SELECT span_ip_cl_acc_hold_trans.cl_number
FROM ...
WHERE ((span_ip_cl_acc_hold_trans.cl_number) Between " & strNumFrom & " And " & strNumTo & " And ((span_ip_cl_acc_hold_trans.proc_date)=" & datProcDate & ");
set qdf = currentdb.createQueryDef("Extract",strSQL)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.