N
NevilleT
I have a form where there is a record selection combo box. Standard
FindFirst code. I have another check box to select a different subset of
records. Tick the box and you change me.rowsource to a different stored
procedure. So far so good. What I also want to do is to change the combo to
a different stored procedure as well.
My problem is that the new combo stored proc has a parameter which is the
CurrentUser - @UserID. I have a field on the form with a ControlSource
"=CurrentUser" so I can refer to the form field.
This is the stored procedure
ALTER PROCEDURE dbo.qryCmbProject_AllAccess
@UserID nvarchar(20)
AS SELECT DISTINCT dbo.tblProject.ProjectNo, dbo.tblProject.ProjectName,
dbo.tblProject.ProjectID, dbo.tblProjectAccess.UserName
FROM dbo.tblProjectAccess LEFT OUTER JOIN
dbo.tblProject ON dbo.tblProjectAccess.ProjectNo =
dbo.tblProject.ProjectNo
WHERE dbo.tblProjectAccess.UserName = @UserID
GO
Problem is I don't know how to pass the parameter to the query which is the
rowsource once the checkbox is ticked. Do I use VBA to create a parameter
when the combo got focus event occurs? Can I add it to the rowsource
property?
FindFirst code. I have another check box to select a different subset of
records. Tick the box and you change me.rowsource to a different stored
procedure. So far so good. What I also want to do is to change the combo to
a different stored procedure as well.
My problem is that the new combo stored proc has a parameter which is the
CurrentUser - @UserID. I have a field on the form with a ControlSource
"=CurrentUser" so I can refer to the form field.
This is the stored procedure
ALTER PROCEDURE dbo.qryCmbProject_AllAccess
@UserID nvarchar(20)
AS SELECT DISTINCT dbo.tblProject.ProjectNo, dbo.tblProject.ProjectName,
dbo.tblProject.ProjectID, dbo.tblProjectAccess.UserName
FROM dbo.tblProjectAccess LEFT OUTER JOIN
dbo.tblProject ON dbo.tblProjectAccess.ProjectNo =
dbo.tblProject.ProjectNo
WHERE dbo.tblProjectAccess.UserName = @UserID
GO
Problem is I don't know how to pass the parameter to the query which is the
rowsource once the checkbox is ticked. Do I use VBA to create a parameter
when the combo got focus event occurs? Can I add it to the rowsource
property?