-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
With stored procedures (SPs) as the RecordSource of Forms, Reports, or
Data Access Pages you can use the Input Parameter property. E.g. (all
one line):
Input Parameter: @BeginDate = Forms!FormName!BeginDateControlName,
@EndDAte = Forms!FormName!EndDateControlName
In VBA you'd have to programatically add the parameter.
== air code ==
dim cn as new adodb.connection
dim rs as adodb.recordset
cn.open CurrentProject.Connection
' SP - for 2 string parameters:
dim strParams as string
strParams = "'" & Forms!FormName!ControlName & "'"
strParams = strParams & ",'" & Forms!FormName!AnotherControl & "'"
set rs = cn.Execute "EXEC ProcedureName " & _
strParams & ", , " & adCmdText
' View - with a date & a number parameter:
' Set up a SELECT string w/ a View as the data source.
dim strSQL as string
strSQL = "SELECT * FROM ViewName WHERE DateColumn = '|1' " & _
"And NumberColumn = |2"
' Set up the parameters (|1 and |2) w/ the values from a form
strSQL = Replace(strSQL, "|1", _
Format(Forms!FormName!DateControlName,"YYYYMMDD"))
strSQL = Replace(strSQL, "|2", Forms!FormName!NumberControlName)
set rs = cn.Execute strSQL, , adCmdText
== end code ==
The Format() of the date control value to "YYYYMMDD" translates the date
to a format SQL'r recognizes. Note the single-quotes around the |1 in
the first assignment of strSQL: dates as string values are delimited by
single quotes.
Both these VBA examples require that the controls have data before they
run.
Use the recordset (rs) as you want.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQImRm4echKqOuFEgEQK1XgCcDH3RuDZQJkxn6xOFrdedTQYcwOkAnRfp
6+wApg83Ld+XDratbbamcsIU
=/tGM
-----END PGP SIGNATURE-----