Code won't run

G

Guest

The visual basic code I have imputed will not run. The seventh line of
code,"Dim dbs As Database" is highlighted, and the message, "Compile Error:
User-defined type not defined" appears.
If anyone has any ideas, I'd appretiate it.


Option Compare Database
Option Explicit

Dim strSymbol As String
Dim dteLineDate As Date
Dim intRef As Integer
Dim strSQL As String
Dim dbs As Database
Dim rst As Recordset

Private Sub CopyData()
On Error GoTo Err_CopyData

strSymbol = InputBox("Enter Symbol Code:")
intRef = -63
dteLineDate = DMin("[DATE]", "[RAW DATA]", "[SYMBOL] = strSymbol")

While intRef < -51
strSQL = "INSERT INTO INTERMEDIATE (SYMBOL, DATE, HIGH, " & _
"LOW, LAST, VOLUME) SELECT [RAW DATA].SYMBOL, " & _
"[RAW DATA].DATE, [RAW DATA].HIGH, [RAW DATA].LOW, " & _
"WHERE (([RAW DATA].SYMBOL = strSymbol) " & _
"AND ([RAW DATA].DATE = dteLineDate))"

DoCmd.RunSQL strSQL

intRef = intRef + 1

NextDate:
dteLineDate = dteLineDate + 1
strSQL = "SELECT * FROM [RAW DATA] WHERE " & _
"(([DATE] = dteLineDate) AND ([SYMBOL] = strSymbol))"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If DCount("*", rst) = 0 Then
Set rst = Nothing
Set dbs = Nothing
GoTo NextDate
Else
Set rst = Nothing
Set dbs = Nothing
End If

Wend

Exit Sub

Err_CopyData:
MsgBox Err.Description
Exit Sub

End Sub
 
G

Guest

Open the code window.
From the Tools menu select References.
if they are not already checked,
scroll down the list and select Microsoft DAO 3.6 Object Library.
If you have a differernt version # that's ok, just select the most recent.


jmonty
 

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

Failure to Run 4
Code will not run 1
Type mismatch 1
No current record. 2
Invalid Use of Null 3
Make table from recordset 2
Where is my code wrong? 3
Export data to multiple excel spreadsheets 2

Top