Do Until

M

mps731

Sorry for the lack of "know how" on my part I am a database neophyte and am
trying to learn as much as I can. So....I am trying to run some code that on
button click a query will run looping through criteria set in table. However,
I keep getting a "Compile Error...Sub or Function not defined." Can someone
help? Here is my code:

Private Sub Detail_Click()
Dim rst As DAO.Recordset
Dim strSQL As String
Dim dbs As DAO.Database

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Definitions-DC List")

DoCmd.OpenQuery "1a-Del Temp Sales Penetation Tbl"


With rst
Do Until rst.EOF = True

strSQL = "SELECT [Temp Product Essbase].[Fiscal Month Abbreviation],
[Temp Product Essbase].[Fiscal Month], [Temp Product Essbase].[Product
Hierarchy], [Temp Product Essbase].[Product Hierarchy Description], [Temp
Product Essbase].[Financial Metrics], [Temp Product Essbase].[Financial
Metrics Description], [Temp Product Essbase].TY AS [DC 89 TY], [Temp Product
Essbase].LY AS [DC 89LY], [Temp Product Essbase].LLY AS [DC 89 LLY], [Temp
Product Essbase].[Plan (RP)] AS [DC 89 Plan] INTO [1b-Demand Center Sales $
Seperation Tbl]"
FROM [Temp Product Essbase]
WHERE ((([Temp Product Essbase].[Financial Metrics Description])
= "Sales $")) & _
" WHERE [Product Hierarchy] = " & rst![Demand Center] & ""

DoCmd.RunSQL strSQL

DoCmd.OpenQuery "1e-Append Sales Penetration to Temp Tbl"

Loop

End Sub
 
R

ruralguy via AccessMonster.com

Names with imbedded spaces (always a bad idea) need to be enclosed in
[brackets] for starters.
DoCmd.OpenQuery "[1a-Del Temp Sales Penetation Tbl]"

Sorry for the lack of "know how" on my part I am a database neophyte and am
trying to learn as much as I can. So....I am trying to run some code that on
button click a query will run looping through criteria set in table. However,
I keep getting a "Compile Error...Sub or Function not defined." Can someone
help? Here is my code:

Private Sub Detail_Click()
Dim rst As DAO.Recordset
Dim strSQL As String
Dim dbs As DAO.Database

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Definitions-DC List")

DoCmd.OpenQuery "1a-Del Temp Sales Penetation Tbl"

With rst
Do Until rst.EOF = True

strSQL = "SELECT [Temp Product Essbase].[Fiscal Month Abbreviation],
[Temp Product Essbase].[Fiscal Month], [Temp Product Essbase].[Product
Hierarchy], [Temp Product Essbase].[Product Hierarchy Description], [Temp
Product Essbase].[Financial Metrics], [Temp Product Essbase].[Financial
Metrics Description], [Temp Product Essbase].TY AS [DC 89 TY], [Temp Product
Essbase].LY AS [DC 89LY], [Temp Product Essbase].LLY AS [DC 89 LLY], [Temp
Product Essbase].[Plan (RP)] AS [DC 89 Plan] INTO [1b-Demand Center Sales $
Seperation Tbl]"
FROM [Temp Product Essbase]
WHERE ((([Temp Product Essbase].[Financial Metrics Description])
= "Sales $")) & _
" WHERE [Product Hierarchy] = " & rst![Demand Center] & ""

DoCmd.RunSQL strSQL

DoCmd.OpenQuery "1e-Append Sales Penetration to Temp Tbl"

Loop

End Sub
 
M

mps731 via AccessMonster.com

Thanks. It looks like the error is on the Private Sub Detail_Click(). I put
brackets around names with embedded spaces and still receive an error.
Names with imbedded spaces (always a bad idea) need to be enclosed in
[brackets] for starters.
DoCmd.OpenQuery "[1a-Del Temp Sales Penetation Tbl]"
Sorry for the lack of "know how" on my part I am a database neophyte and am
trying to learn as much as I can. So....I am trying to run some code that on
[quoted text clipped - 35 lines]
 
R

ruralguy via AccessMonster.com

What is the name of your CommandButton? If you named it "Detail" that is
also the name of a section of your form. Try naming it cmdDetail instead.
Thanks. It looks like the error is on the Private Sub Detail_Click(). I put
brackets around names with embedded spaces and still receive an error.
Names with imbedded spaces (always a bad idea) need to be enclosed in
[brackets] for starters.
[quoted text clipped - 5 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL "Where" issue 1
Create TBL SQL error 1

Top