ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Undefined function error (https://www.excelbanter.com/excel-discussion-misc-queries/92180-undefined-function-error.html)

CLamar

Undefined function error
 
I keep getting the undefined function error when executing my code, although
it has already been defined. both functions are defined as public sub



CLR

Undefined function error
 
Post your code.......maybe someone can help.

Vaya con Dios,
Chuck, CABGx3



"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



CLamar

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

CLR

Undefined function error
 
Maybe..........
InitialSelec = Selec

instead of
InitialSelc = Selec

Vaya con Dios,
Chuck, CABGx3



"CLamar" wrote:



"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



All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com