Nothing is obvious with ADP. SQL-Server doesn't know anything about the
local parameters in an ADP project, so these must be explicited transferred
to the SQL-Server. There are three ways of doing this: first, you can build
the record source to a string that will directly make the select statement
with the right values, knowing that you must use the single quote ' as the
string and date delimiters:
Me.RecordSource = "SELECT HRRM.HRRef, HRRM.LastContactDate, HRRM.State
FROM HRRM WHERE (((HRRM.LastContactDate) Between '" &
[Forms]![CallList_Frm]![BegDate] & "' And
'" & [Forms]![CallList_Frm]![EndDate]) & "' " ...
I cannot finish the translation because your LIKE clause doesn't mean
anything to me the way that you have written it.
Second, you can write a stored procedure and again set the record source to
make an EXEC call to this SP with the right values:
Me.RecordSource = "EXEC MyStoredProcedure '" &
[Forms]![CallList_Frm]![BegDate] & "', '" & &
[Forms]![CallList_Frm]![EndDate]) & "' " ....
Or you can set the RecordSource to the name of the SP and use the
InputParameters properties to send the values:
Me.RecordSource = "dbo.MyStoredProcedure"
or also:
Me.RecordSourceQualifier = "dbo"
Me.RecordSource = "MyStoredProcedure"
Me.InputParameters = "@BegDate DateTime = [Forms]![CallList_Frm]![EndDate],
@BegDate DateTime = [Forms]![CallList_Frm]![EndDate], @BegState nvarchar
(50) = [Forms]![CallList_Frm].[BegState], ...
and for the Stored Procedure:
CREATE PROCEDURE dbo.MyStoredProcedure
(
@BegDate DateTime,
@EndDate DateTime,
@BegState nvarchar (50),
@EndState nvarchar (50),
@BegSkill nvarchar (255),
@EndSkill nvarchar (255),
)
AS
SELECT HRRM.HRRef, HRRM.LastContactDate, HRRM.State
FROM HRRM
WHERE (((HRRM.LastContactDate) Between @BegDate And @EndDate) AND
((HRRM.State) Like
(([HRRM].[State]) = @BegState Or @BegState Is Null)))
GO
In your piece of code, you have repeated two times the parameter @BegDate
and the LIKE clause that you have written doesn't make sense to me. Also,
there is no ; at the end of a sql statement on SQL-Server.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Kobi" <Kobi@discussions.microsoft.com> wrote in message
news:3EC2E0CC-7F6F-4804-AE8B-2A08BC61CECF@microsoft.com...
|