LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Call function with adodb.connection Problem

Hello guys,

I have a problem with a function that call another function

So, for exampple I have this function, info that gives me all
information about client , and this function call another function
calling getclientnumber (adodb.connection, string).

the problem is that when I call this function I have a Loop result all
the time calling the same code. I do not know why might a problem with
the adodb.connection


Public Function Info(ByVal cndb As ADODB.Connection)
On Error GoTo Info_Err

'Variables description
'======================

Dim dtmStart As Date
Dim r As Integer, i As Integer
Dim size As Integer
Dim varInfo(1 To 1000, 1 To 68) As Variant
Dim strCode As String, strCurrency As String, Name as String
Dim rsCode As ADODB.Recordset
Dim vartblFee(1 To 4, 1 To 4) As Variant

Set rsCode = New ADODB.Recordset


rsCode.ActiveConnection = cndb
rstCode.Open "select * from clientcode"


r = 2

Do While Not rsCode.EOF

strCode = rsCode.Fields(1).Value
rsCode.MoveNext

strClientNumber = GetClientNumber(cndb, strtCode)
Name = rsCode.Fields(2).Value


Cells(r, 1) = strtCode
Cells(r, 2) = Name
Cells(r, 3) = ""
Cells(r, 4) = ""
Cells(r, 5) = ""
Cells(r, 6) = ""
Cells(r, 7) = strClientNumber

r = r + 1

Loop


rsCode.Close
Set rsCode = Nothing

cndb.Close
Set cndb = Nothing

Info_Err:
'ActiveCell.Value = CVErr(xlErrNA)

End Function



'Function GetClientNumber

Public Function GetClientNumber(ByVal cndb As ADODB.Connection, strCode
As String) As String
On Error GoTo GetClientNumber_Err

Dim strSQL As String
Dim rsClient As ADODB.Recordset
Dim strClientNumber As String, strClientCall As String


Set rsClient = New ADODB.Recordset


strSQL = "select clientnumber from Clientview where code = '" & strCode
& " '"


rsClient.ActiveConnection = cndb
rsClient.Open strSQL
strClient = rs.Fields(0).Value

strClientCall = GetClientNumber(cndb, strClient) 'problem here

rsClient.Close
cndb.Close

Set cndb = Nothing
Set rsClient = Nothing

Getcurrrency_Err:
GetClientNumber = CVErr(xlErrNA)
Exit Function

End Function

Any help is appreciated thank you :)

Ina

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB Connection fi.or.jp.de Excel Worksheet Functions 0 September 9th 09 09:23 PM
ADODB Connection Problem spardey Excel Programming 5 December 3rd 05 11:00 PM
VBA excel - problem with having clause in sql with adodb.connection/recordset ukp9999 Excel Programming 3 November 21st 05 07:48 AM
ADODB Connection Problem alpder Excel Programming 3 November 4th 05 09:28 PM
ADODB Connection String Nigel C Excel Programming 1 August 20th 05 07:29 AM


All times are GMT +1. The time now is 08:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"