Compile Error

  • Thread starter Michael Hudston
  • Start date
M

Michael Hudston

Can anyone tell me why I get a "Compile Error - User Defined type not
defined" on my record set.

How do I define my record set?

Mike

Sub Show_Status_Chart_Click()
On Error GoTo Show_Status_Chart_Err

' Dimension arrays for recordset & excel etc

Dim inStat As ADODB.Recordset
Dim objExcel As Excel.Application
Dim objSheet As Excel.Worksheet
Dim objChart As Excel.Chart

Dim fld As ADODB.Field
Dim intCol As Integer
Dim intRow As Integer

' Populate the recordset.

Set inStat = New ADODB.Recordset
inStat.Open "BE_Status_Updates_Query", CurrentProject.Connection

' Launch Excel and Create WorkSheet

Set objExcel = New Excel.Application
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveSheet

' Transfer the data
' Create the Headings

For intCol = 0 To inStat.Fields.Count - 1
Set fld = inStat.Fields(intCol)
objSheet.Cells(1, intCol + 1) = fld.Name
Next intCol

' Transfer the actual Data
intRow = 2

Do Until inStat.EOF
For intCol = 0 To Status.Fields.Count - 1
objSheet.Cells(intRow, intCol + 1) = inStat.Fields(intCol).Value
Next intCol
inStat.MoveNext
intRow = intRow + 1
Loop

' Add New Chart

objExcel.Charts.Add
Set objChart = objExcel.ActiveChart

' Set up the Chart
objChart.ChartType = xl3dPie
objChart.SetSourceData Source:=objSheet.Range("A1:B" & CStr(intRow -
1)), Plotby:=xlColumns
objChart.Location xlLocationAsNewSheet
objChart.HasTitle = True
objChart.ChartTitle.Characters.Text = "Incident Status by Date"

objExcel.Visible = True

Show_Status_Chart_Exit:
Exit Sub

Show_Status_Chart_Err:
MsgBox Error$
Resume Show_Status_Chart_Exit

End Sub
 
D

Douglas J. Steele

If the Reference option is grayed out, you must have code running.

Look under the Run menu and click on End.
 
M

Michael Hudston

Ok I have been having a stupid day. Fixed now as have the activeX reference
running now

Cheers
 

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

Top