If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Access97 Error sub or function not defined

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-03, 16:42
Alexxx12 Alexxx12 is offline
Registered User
 
Join Date: Sep 2002
Location: NJ
Posts: 139
Access97 Error sub or function not defined

Hi,

I have copied the code from Mastering Access97 Development by Alison Balters, page 724, as I learn to play with Access and the accessing of other MS applications with code. The code is located bellow. However, i get an error:

Sub or Function not defined at this line


" Source:=Range("A1:B22"), " with the word "Range" blue highlighted. I don't understand why? can somebody help me with this?? Am I missing something??



Public Sub cmdCreateGraph_Click()
On Error GoTo cmdCreateGraph_Err
Dim db As DATABASE
Dim rs As Recordset
Dim fld As Field
Dim objWS As Object
Dim intRowCount As Integer
Dim intColCount As Integer

DoCmd.Hourglass True
Set db = CurrentDb

If CreateRecordset(db, rs, "qrySalesByCountry") Then
If CreateExcelObj() Then
gobjExcel.Workbooks.Add
Set objWS = gobjExcel.ActiveSheet
intRowCount = 1
intColCount = 1
For Each fld In rs.Fields
If fld.Type <> dbLongBinary Then
objWS.Cells(1, intColCount).Value = fld.Name
intColCount = intColCount + 1
End If
Next fld

Do Until rs.EOF
intColCount = 1
intRowCount = intRowCount + 1
For Each fld In rs.Fields
If fld.Type <> dbLongBinary Then
objWS.Cells(intRowCount, intColCount).Value = fld.Name
intColCount = intColCount + 1
End If
Next fld
rs.MoveNext
Loop
gobjExcel.Columns("A:B").SELECT
gobjExcel.Columns("A:B").EntireColumn.AutoFit
gobjExcel.Range("A1").SELECT
gobjExcel.ActiveCell.CurrentRegion.SELECT
gobjExcel.ActiveSheet.ChartObjects.Add(135.75, 14.25, 607.75, 301).SELECT
gobjExcel.ActiveChart.ChartWizard Source:=Range("A1:B22"), _
Gallery:=xlColumn, _
Format:=6, PlotBy:=xlColumns, CategoryLabels:=1, SeriesLabels _
:=1, HasLegend:=1, Title:="Sales By Country Richard", CategoryTitle _
:="", ValueTitle:="", ExtraTitle:=""

gobjExcel.Visible = True
Else
MsgBox "Excel Not Successfully Launched"
End If
Else
MsgBox " Too many Records to send to excel"
End If
DoCmd.Hourglass False

cmdCreateGraph_Exit:
Set db = Nothing
Set rs = Nothing
Set fld = Nothing
Set objWS = Nothing
DoCmd.Hourglass False
Exit Sub

cmdCreateGraph_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Resume cmdCreateGraph_Exit



End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On