skyline666
Programmer
Hi,
I have a database called Risk using Access 2003, with Risk linked to SQL Server 2005. I have a form on Access (called Form1 for now), with a subform linked to that form. On the form (not subform) I have a combo box called ProjectCombo and a list box called ProjectList. At the moment ProjectCombo returns a list of all master projects (the field called ProjectName) from a table in a different database (called Master) on SQL, and ProjectList returns a list of all sub projects (the field called Project) from the same different database.
There can be many sub projects for each master project. For example, a master project called Deep Water has many sub projects called Deep Water - Storage, Deep Water - Test, etc. Both master and sub project have code identifiers (fields called ProjectMasterCode and ProjectSubCode respectively). For example Deep Water could be DW, and Deep Water - Storage could be DW01, Deep Water - Test could be DW02 etc.
What I would like is for the user to select a master project from ProjectCombo, and then all sub projects associated with that master project appear in ProjectList automatically. I can't make the list box bound to the combo box as it can only be bound to the main form.
Some code that might help. Note that all stored procedures were made in SQL.
ProjectCombo uses a stored procedure called usp_MasterProjects:
ProjectList uses a stored procedure called usp_ProjectList:
The master projects and sub projects are linked by a ProjectID (each master project has a ProjectID, and so all sub projects for each master project have the same ProjectID).
In usp_ProjectList, I would like Master.dbo.SubProjects.ProjectID to equal [Forms]![Form1]![ProjectCombo], or something along those lines. If this can't be done, then some code in VBA will most probably have to be done.
Note I did try the [Forms!]... bit, but got an error when executed in SQL saying Incorrect syntax near !. I think this is becuase you cant do this in SQL, but if the stored procedure is to be changed, it will need to be done in SQL as Access wont allow changes to the stored procedures.
So to sum up, I want ProjectList to return values when ProjectCombo is selected, and either a modification to the stored proc usp_ProjectList, or some code in VBA, to do it with.
If you need any more info please ask.
Many thanks and I hope this makes sense,
Andrew
I have a database called Risk using Access 2003, with Risk linked to SQL Server 2005. I have a form on Access (called Form1 for now), with a subform linked to that form. On the form (not subform) I have a combo box called ProjectCombo and a list box called ProjectList. At the moment ProjectCombo returns a list of all master projects (the field called ProjectName) from a table in a different database (called Master) on SQL, and ProjectList returns a list of all sub projects (the field called Project) from the same different database.
There can be many sub projects for each master project. For example, a master project called Deep Water has many sub projects called Deep Water - Storage, Deep Water - Test, etc. Both master and sub project have code identifiers (fields called ProjectMasterCode and ProjectSubCode respectively). For example Deep Water could be DW, and Deep Water - Storage could be DW01, Deep Water - Test could be DW02 etc.
What I would like is for the user to select a master project from ProjectCombo, and then all sub projects associated with that master project appear in ProjectList automatically. I can't make the list box bound to the combo box as it can only be bound to the main form.
Some code that might help. Note that all stored procedures were made in SQL.
ProjectCombo uses a stored procedure called usp_MasterProjects:
Code:
ALTER PROCEDURE [dbo].[usp_MasterProjects]
AS
set nocount on
SELECT *
FROM Master.dbo.MasterProjects
ORDER BY ProjectName
set nocount off
ProjectList uses a stored procedure called usp_ProjectList:
Code:
ALTER PROCEDURE [dbo].[usp_ProjectList]
AS
set nocount on
SELECT ProjectMasterCode + ' - ' + CAST(ProjectSubCode AS varchar(6)) + ' - ' + ProjectName AS Project
FROM Master.dbo.SubProjects
WHERE Master.dbo.SubProjects.ProjectID = Master.dbo.SubProjects.ProjectID
ORDER BY Project
set nocount off
The master projects and sub projects are linked by a ProjectID (each master project has a ProjectID, and so all sub projects for each master project have the same ProjectID).
In usp_ProjectList, I would like Master.dbo.SubProjects.ProjectID to equal [Forms]![Form1]![ProjectCombo], or something along those lines. If this can't be done, then some code in VBA will most probably have to be done.
Note I did try the [Forms!]... bit, but got an error when executed in SQL saying Incorrect syntax near !. I think this is becuase you cant do this in SQL, but if the stored procedure is to be changed, it will need to be done in SQL as Access wont allow changes to the stored procedures.
So to sum up, I want ProjectList to return values when ProjectCombo is selected, and either a modification to the stored proc usp_ProjectList, or some code in VBA, to do it with.
If you need any more info please ask.
Many thanks and I hope this makes sense,
Andrew