× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here's how I do it...

I have a button... it calls this...

With the calendar1&2 values I used via the form controls..

That's about it...  I have other stuff I do, but this is the relevant
code... Also you will want to reference the ADO (ActiveX Data Objects) I
used the mdac 2.8

Hth, tim

--
Odbcdsn is the DSN name I used when I created my odbc connection...

Private Sub CommandButton1_Click()

'Defining variables
Dim cnOra As ADODB.Connection
Dim rsOra As ADODB.Recordset
Dim db_name As String
Dim UserName As String
Dim Password As String

Set cnOra = New ADODB.Connection
Set rsOra = New ADODB.Recordset

Dim wsSheet As Worksheet
Dim Sheet2 As Worksheet
Dim Sheet3 As Worksheet

Set wsSheet = ThisWorkbook.Worksheets(1)
Set Sheet2 = ThisWorkbook.Worksheets(2)

Set Sheet3 = ThisWorkbook.Worksheets(3)

newStrDate = Format(UserForm1.Calendar1.Value, "yyyymmdd")
newEndDate = Format(UserForm1.Calendar2.Value, "yyyymmdd")

db_name = "odbcdsn"
UserName = "superuser"
Password = "suprpassword"

'Making an ODBC connection according to ADO
cnOra.Open "DSN=" + db_name + ";UID=" + UserName + ";PWD=" _
& Password + ";"
rsOra.CursorLocation = adUseServer

'Running a query
rsOra.Open "select * from ICDBFA.ICPAJ where ajtcod = '21' and (ajatyp >=
'A' and ajatyp <= 'Z') and ajatyp <> 'ISSUE' and (ajtdat >= " + newStrDate +
" and ajtdat <= " + newEndDate + ")", cnOra, adOpenForwardOnly

'Passing on data from the recordset to a variable or cell.
'Notice that the column name or alias is used to address
'data in the recordset.

wsSheet.Range("A1").CurrentRegion.Clear

' the 1st row is the resultsets column headers

fldCount = rsOra.Fields.Count
    For iCol = 1 To fldCount
        wsSheet.Cells(1, iCol).Value = rsOra.Fields(iCol - 1).Name
    Next


' copy the result set at row#2, leaving the header in tact.
wsSheet.Cells(2, 1).CopyFromRecordset rsOra



rsOra.Close



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Chavez, Rene (NBC
Universal)
Sent: Tuesday, May 09, 2006 1:05 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Automating downloading an Excel spread sheet to the iSeries using a
macro

> I have been given a project to accomplish the above.
> I can't seem to get a straight approach from anyone, 
> Can you help.
> 
> Thanks in advance,  Rene


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.