View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
CLamar
 
Posts: n/a
Default Undefined function error



"CLamar" wrote:

I keep getting the undefined function error when executing my code, although
it has already been defined. both functions are defined as public sub. InitialSelec inside the SQL statement with the asterisks is when the undefined error pops up.

Function InitialSelec()
'Assigns the selected value inside the List Box to a variable
For w = 0 To Sheets("Sheet1").LstBatchnum.ListCount - 1
If Sheets("Sheet1").LstBatchnum.Selected(w) Then _
Selec = Selec & Sheets("Sheet1").LstBatchnum.List(k)
InitialSelc = Selec
Next w
End Function


Set Recordset = New ADODB.Recordset

With Recordset
Call InitialSelec
**Src = "SELECT * FROM tblResults WHERE Batch = InitialSelec()"
.Open Source:=Src, ActiveConnection:=Connection2

'For Col = 0 To Recordset.Fields.Count - 1
' Sheets("Sheets3").Range("A1").Offset(0, Col).Value =
Recordset.Fields(Col).Name
'Next

Sheets("Sheet3").Range("A1").Offset(1, 0).CopyFromRecordset
Recordset

'Copies the data inside the recordset into a List Box
For Row = 2 To Recordset.Properties.Count - 1
Sheets("Sheet1").LstTirenum.AddItem
Sheets("Sheet3").Cells(Row, 4)
Next Row

End With