Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Procedure Call

inI have been using a procedure call with a procedure to execute the sql
connection steps defined a the getdata procedure but I noticed today when the
cmd_go_click procedure gets to the getdata statement, it terminates when it
should begin running the statements in the getdata procedure. Any ideas why
this would terminate?

Here is a sample:

Public sub cmd_go_click ()
'Get data - run ADO connection module
getdata
end sub

Public Sub getdata()
stcon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\itcfile02\FCDAttachment\PMNDocs\PMN.mdb;" 'ACCESS
2000
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
strsql = "SELECT AddresseeCity, AddresseeState, Mailingcity,
mailingstate, country, addresseename, addresseeaddress, " & _
"addresseezip, labeldate, labelnumber, mailservice,
typenarcotic, totalpostage, originzip, " & _
"WgtPkginLbs, ozs, flatrate, dimensions FROM " & tbl & " WHERE
" & _
"labeldate =#" & beg & "# and labeldate <=#" & fin & "#;"
cnn.Open stcon
rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
recs = rst.RecordCount
If recs = 0 Then
Exit Sub
MsgBox "A search of the available data returned " & recs & "
record(s)." & vbCrLf & _
"Please run the report again with different selection
criteria.", vbInformation, "Data"
End If
Worksheets("Data").Select
i = 1
For Each fld In rst.Fields
ActiveSheet.Cells(1, i).Value = fld.Name
i = i + 1
Next fld
'On Error Resume Next
Worksheets("Data").Range("A2").CopyFromRecordset rst
cnn.Close
Set rst = Nothing
end sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Procedure Call

put
OPTION EXPLICIT at the start (ie the very firat line) of your code module,
then DIM each variable. use DEBUG/COMPILE to check this

then step (F8) through the code. Check that the connection opens and that if
it does, that the reciordset populates correctly.



"Mike" wrote:

inI have been using a procedure call with a procedure to execute the sql
connection steps defined a the getdata procedure but I noticed today when the
cmd_go_click procedure gets to the getdata statement, it terminates when it
should begin running the statements in the getdata procedure. Any ideas why
this would terminate?

Here is a sample:

Public sub cmd_go_click ()
'Get data - run ADO connection module
getdata
end sub

Public Sub getdata()
stcon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\itcfile02\FCDAttachment\PMNDocs\PMN.mdb;" 'ACCESS
2000
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
strsql = "SELECT AddresseeCity, AddresseeState, Mailingcity,
mailingstate, country, addresseename, addresseeaddress, " & _
"addresseezip, labeldate, labelnumber, mailservice,
typenarcotic, totalpostage, originzip, " & _
"WgtPkginLbs, ozs, flatrate, dimensions FROM " & tbl & " WHERE
" & _
"labeldate =#" & beg & "# and labeldate <=#" & fin & "#;"
cnn.Open stcon
rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
recs = rst.RecordCount
If recs = 0 Then
Exit Sub
MsgBox "A search of the available data returned " & recs & "
record(s)." & vbCrLf & _
"Please run the report again with different selection
criteria.", vbInformation, "Data"
End If
Worksheets("Data").Select
i = 1
For Each fld In rst.Fields
ActiveSheet.Cells(1, i).Value = fld.Name
i = i + 1
Next fld
'On Error Resume Next
Worksheets("Data").Range("A2").CopyFromRecordset rst
cnn.Close
Set rst = Nothing
end sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Procedure Call

I have option explicit and dim my variables at the beginning.

"Patrick Molloy" wrote:

put
OPTION EXPLICIT at the start (ie the very firat line) of your code module,
then DIM each variable. use DEBUG/COMPILE to check this

then step (F8) through the code. Check that the connection opens and that if
it does, that the reciordset populates correctly.



"Mike" wrote:

inI have been using a procedure call with a procedure to execute the sql
connection steps defined a the getdata procedure but I noticed today when the
cmd_go_click procedure gets to the getdata statement, it terminates when it
should begin running the statements in the getdata procedure. Any ideas why
this would terminate?

Here is a sample:

Public sub cmd_go_click ()
'Get data - run ADO connection module
getdata
end sub

Public Sub getdata()
stcon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\itcfile02\FCDAttachment\PMNDocs\PMN.mdb;" 'ACCESS
2000
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
strsql = "SELECT AddresseeCity, AddresseeState, Mailingcity,
mailingstate, country, addresseename, addresseeaddress, " & _
"addresseezip, labeldate, labelnumber, mailservice,
typenarcotic, totalpostage, originzip, " & _
"WgtPkginLbs, ozs, flatrate, dimensions FROM " & tbl & " WHERE
" & _
"labeldate =#" & beg & "# and labeldate <=#" & fin & "#;"
cnn.Open stcon
rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
recs = rst.RecordCount
If recs = 0 Then
Exit Sub
MsgBox "A search of the available data returned " & recs & "
record(s)." & vbCrLf & _
"Please run the report again with different selection
criteria.", vbInformation, "Data"
End If
Worksheets("Data").Select
i = 1
For Each fld In rst.Fields
ActiveSheet.Cells(1, i).Value = fld.Name
i = i + 1
Next fld
'On Error Resume Next
Worksheets("Data").Range("A2").CopyFromRecordset rst
cnn.Close
Set rst = Nothing
end sub

Reply
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
procedure call BorisS Excel Programming 1 September 18th 06 07:16 AM
Call Procedure Ronbo Excel Programming 4 February 23rd 05 08:11 PM
Where else to look for procedure call Lulu Excel Programming 0 November 24th 04 03:07 PM
call procedure bob Excel Programming 1 August 9th 03 12:40 AM
procedure won't call John Gittins Excel Programming 0 August 5th 03 08:17 PM


All times are GMT +1. The time now is 11:20 PM.

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

About Us

"It's about Microsoft Excel"