T
The Yankees Stat Zone
Hi,
I need help to automate a manual process. Currently the db uses a
macro that does the following:
1. Opens a query that lists names of sales people that have had sales
since the last export date (the date is stored in a table).
2. Kicks off a parameter query where the user types the sales person
name (from above query)
3. Exports that query into htm in a directory that the user chooses
(it's the intranet shared directory, user browses to the directory and
is intructed to overwrite the existing salesperson.htm file)
4. inserts current timestamp into the last export date field.
5. Closes the list.
What I'd like to do is:
Create a module that will do this:
1. Use the query referenced in 1 above as a recordset.
2. Insert the name it finds in the recordset into the parameter query
(no typing needed by user anymore)
3. Export the that query into a predefined location (location stored
in a table) without the user browsing to find the location, using the
shortname from within the recordset.
4. loop the module for every name in the recordset.
5. update the last export date.
The salespersonlist query is shown as follows:
SalesPerson ShortName
George Foreman geofor
Leonard Spinks leospi
Muhammed Ali muhali
Lennox Lewis lenlew
Mike Tyson miktys
Here's the air-code that I envision, very loosely written and
untested, help me clean up this code so it works.
Function ExportSales()
On Error GoTo Err_Command0_Click
Dim dbSalesRevenue As Database
Dim rstSalesPersonList As Recordset
Dim stSalesPerson As String
Dim stShortName As String
Dim stExportLocation As String
Dim stTemplateLocation As String
Set dbSalesRevenue = CurrentDb()
Set rstSalesPersonList =
dbSalesRevenue.OpenRecordset("qry_SalesPersonList", dbOpenDynaset)
stShort = DLookup("[ShortName]", "qry_list_of_salespersons")
stLocation = DLookup("Private", "Settings") & "private\Query
Template.htm"
stExport = DLookup("Export", "Settings")
DoCmd.OutputTo acOutputQuery, "Parameter Query name", acFormatHTML,
stExportLocation & rstSalesPersonList.stShortname & ".htm", ,
stTemplateLocation
Exit_Command0_Click:
Exit Function
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Function
To summarize, my questions:
Where does the Loop go?
where does the do until EOF go?
How do I reference the rst in the parameter query?
How do I reference the rst as the html file name?
This is my first stab at doing a loop module, couldn't find a any
concrete information on the web would be helpful if anyone has a link
with a tutorial I would appreciate it.
YF4E
I need help to automate a manual process. Currently the db uses a
macro that does the following:
1. Opens a query that lists names of sales people that have had sales
since the last export date (the date is stored in a table).
2. Kicks off a parameter query where the user types the sales person
name (from above query)
3. Exports that query into htm in a directory that the user chooses
(it's the intranet shared directory, user browses to the directory and
is intructed to overwrite the existing salesperson.htm file)
4. inserts current timestamp into the last export date field.
5. Closes the list.
What I'd like to do is:
Create a module that will do this:
1. Use the query referenced in 1 above as a recordset.
2. Insert the name it finds in the recordset into the parameter query
(no typing needed by user anymore)
3. Export the that query into a predefined location (location stored
in a table) without the user browsing to find the location, using the
shortname from within the recordset.
4. loop the module for every name in the recordset.
5. update the last export date.
The salespersonlist query is shown as follows:
SalesPerson ShortName
George Foreman geofor
Leonard Spinks leospi
Muhammed Ali muhali
Lennox Lewis lenlew
Mike Tyson miktys
Here's the air-code that I envision, very loosely written and
untested, help me clean up this code so it works.
Function ExportSales()
On Error GoTo Err_Command0_Click
Dim dbSalesRevenue As Database
Dim rstSalesPersonList As Recordset
Dim stSalesPerson As String
Dim stShortName As String
Dim stExportLocation As String
Dim stTemplateLocation As String
Set dbSalesRevenue = CurrentDb()
Set rstSalesPersonList =
dbSalesRevenue.OpenRecordset("qry_SalesPersonList", dbOpenDynaset)
stShort = DLookup("[ShortName]", "qry_list_of_salespersons")
stLocation = DLookup("Private", "Settings") & "private\Query
Template.htm"
stExport = DLookup("Export", "Settings")
DoCmd.OutputTo acOutputQuery, "Parameter Query name", acFormatHTML,
stExportLocation & rstSalesPersonList.stShortname & ".htm", ,
stTemplateLocation
Exit_Command0_Click:
Exit Function
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Function
To summarize, my questions:
Where does the Loop go?
where does the do until EOF go?
How do I reference the rst in the parameter query?
How do I reference the rst as the html file name?
This is my first stab at doing a loop module, couldn't find a any
concrete information on the web would be helpful if anyone has a link
with a tutorial I would appreciate it.
YF4E