AJParkinson
Technical User
I know this sounds lazy, but I need to start somewhere, and fast!
My normal area of working is within an MDB file and am quite used to creating connections from Access 2000 to SQL7 - (DAO connnection only though), and passing parameters via VBA functions to the queries.
Once I've been simply stepped through the basics of something I can generally pick it up and develop it from there. I could do with a simple walk through the following for within an ADP file - any help will be greatly appreciated.
What I need is to pass variables created by users selecting options in form through to the view that generates a report.
Access 2000 ADP > SQL7
Created so far:
One Report, one Form, one View, one Module ? (I will be generating many different reports once I've got the hang of it so I'll reuse code where I can).
At the moment this all works fine, but I need to filter down the data -
On this particular form, the user needs to select a 'territory' from the form, and by default using this particular form will select data from between a set of dates (always the previous month - start to end) and a status.
I have got the code in place to assign values to variables in the VBA code but I'm struggling to understand how to pass them to the view.
Please could somebody comment out a simple step by step for this, particularly any stored procedure creation including connection exlpanation and what type of variable declarations are allowed.
I've read though some of the threads but have failed to relate it back to how I want to use it.
The variables I've created in VBA to be passed are: mer_sdate & mer_edate (for the between criteria), mer_terr, and mer_stat
Below is the SQL behind the view in the ADP with the Where criteria 'pre-set' obviously this is where I need to pass the variables to.
I've never written any stored procedures before, and as the SQL db that I'm connecting to is our main db I don't wish to screw anything up!
Lastly a couple of asides - the between dates above, would this exclude anything on the 30th? do I need to change it to the 1st of the next month to be fully inclusive? and what does the '102' mean?
Once again, any help will be greatly appreciated.
Andrew
My normal area of working is within an MDB file and am quite used to creating connections from Access 2000 to SQL7 - (DAO connnection only though), and passing parameters via VBA functions to the queries.
Once I've been simply stepped through the basics of something I can generally pick it up and develop it from there. I could do with a simple walk through the following for within an ADP file - any help will be greatly appreciated.
What I need is to pass variables created by users selecting options in form through to the view that generates a report.
Access 2000 ADP > SQL7
Created so far:
One Report, one Form, one View, one Module ? (I will be generating many different reports once I've got the hang of it so I'll reuse code where I can).
At the moment this all works fine, but I need to filter down the data -
On this particular form, the user needs to select a 'territory' from the form, and by default using this particular form will select data from between a set of dates (always the previous month - start to end) and a status.
I have got the code in place to assign values to variables in the VBA code but I'm struggling to understand how to pass them to the view.
Please could somebody comment out a simple step by step for this, particularly any stored procedure creation including connection exlpanation and what type of variable declarations are allowed.
I've read though some of the threads but have failed to relate it back to how I want to use it.
The variables I've created in VBA to be passed are: mer_sdate & mer_edate (for the between criteria), mer_terr, and mer_stat
Below is the SQL behind the view in the ADP with the Where criteria 'pre-set' obviously this is where I need to pass the variables to.
Code:
SELECT dbo.SalesLead.reference AS [Lead Reference],
dbo.SalesLead.total_price AS [Total Customer Price],
dbo.SalesLead.ClosedDate AS [Closed Date],
dbo.[l_Lead Status].description AS [Lead Status],
dbo.[l_Sales Territory].description AS [Sales Territory],
dbo.Company.name AS [Main Company],
dbo.Users.username AS Owner
FROM dbo.SalesLead INNER JOIN
dbo.[l_Lead Status] ON
dbo.SalesLead.stage = dbo.[l_Lead Status].code INNER JOIN
dbo.[l_Sales Territory] ON
dbo.SalesLead.class = dbo.[l_Sales Territory].code INNER JOIN
dbo.Company ON
dbo.SalesLead.company_id = dbo.Company.id INNER JOIN
dbo.Users ON dbo.SalesLead.owner = dbo.Users.id
WHERE (dbo.[l_Sales Territory].description = N'Central') AND
(dbo.[l_Lead Status].description LIKE N'Confirmed%') AND
(dbo.SalesLead.ClosedDate BETWEEN CONVERT(DATETIME,
'2004-04-01 00:00:00', 102) AND CONVERT(DATETIME,
'2004-04-30 00:00:00', 102))
I've never written any stored procedures before, and as the SQL db that I'm connecting to is our main db I don't wish to screw anything up!
Lastly a couple of asides - the between dates above, would this exclude anything on the 30th? do I need to change it to the 1st of the next month to be fully inclusive? and what does the '102' mean?
Once again, any help will be greatly appreciated.
Andrew