Hello There,
I would like to use the ADODB.Connection (SQL) to fetch the data from other workbook.
I have 3 excel workbooks as follows. :
1. Master File.xlsx
This contains all Master Data Tables: Customer, Vendor, Currency and Transaction.
The Customer, Vendor and Currency has 2 columns, Code and it's respective names.
The Data Table Transaction has columns: Transaction Number Transaction Date, Customer Code, Vendor Code, Currency Code, Amount
2. Application File.xlsm
This file contains all the logic and various UserForms to read and write data to the above Master File. In the original file , we do not use any SQL yet.
There are 2 modules:
. A. InitializeEnvironment: Initialize the Public variables for workbooks, worksheets, tables, etc.
. B. ExecuteReport: Which calls the VBA code for report
3. Report Template File.xlsx
This is the report template file. A new file for below requirement.
This contains a Data Table: Tbl_Report and contains one column Seq.
All the above files are located in the same folder. For sample purpose I have kept the files focused on this requirement only.
The requirement is as follows:
In the Application File, worksheet Criteria there are 2 parameters Transaction From and Transaction To Date and a push button.
A. On click Push Button, it should check if the file 3. Report Template File exists, if yes then proceed, else Msgbox "File Not exists" and exit sub.
B. It should get all the rows from DataTable: Transactions (Master File.xlsx), whose Transaction Date is between parameters Transaction From and Transaction To Date.
It should link to the related Data Tables Customer, Vendor and Currency and get it's related Codes' Names for every Transaction row fetched.
C. If the SQL number of rows fetched is greater than 1, then it should:
. 1. make a copy of the 3. Report Template File and rename it to "Transaction Report.xlsx"
. 2. Insert fethced rows into table Tbl_report
. 3. Save file in a folder "Reports" in the same path of the workbook.
. 4. Close the "Transaction Report.xlsx"
D. Display message "Report created " .Name of the File & Total Records in the file
I have attached the sample files for your reference.
Look forward to hearing from you.
Regards,
Don
I would like to use the ADODB.Connection (SQL) to fetch the data from other workbook.
I have 3 excel workbooks as follows. :
1. Master File.xlsx
This contains all Master Data Tables: Customer, Vendor, Currency and Transaction.
The Customer, Vendor and Currency has 2 columns, Code and it's respective names.
The Data Table Transaction has columns: Transaction Number Transaction Date, Customer Code, Vendor Code, Currency Code, Amount
2. Application File.xlsm
This file contains all the logic and various UserForms to read and write data to the above Master File. In the original file , we do not use any SQL yet.
There are 2 modules:
. A. InitializeEnvironment: Initialize the Public variables for workbooks, worksheets, tables, etc.
. B. ExecuteReport: Which calls the VBA code for report
3. Report Template File.xlsx
This is the report template file. A new file for below requirement.
This contains a Data Table: Tbl_Report and contains one column Seq.
All the above files are located in the same folder. For sample purpose I have kept the files focused on this requirement only.
The requirement is as follows:
In the Application File, worksheet Criteria there are 2 parameters Transaction From and Transaction To Date and a push button.
A. On click Push Button, it should check if the file 3. Report Template File exists, if yes then proceed, else Msgbox "File Not exists" and exit sub.
B. It should get all the rows from DataTable: Transactions (Master File.xlsx), whose Transaction Date is between parameters Transaction From and Transaction To Date.
It should link to the related Data Tables Customer, Vendor and Currency and get it's related Codes' Names for every Transaction row fetched.
C. If the SQL number of rows fetched is greater than 1, then it should:
. 1. make a copy of the 3. Report Template File and rename it to "Transaction Report.xlsx"
. 2. Insert fethced rows into table Tbl_report
. 3. Save file in a folder "Reports" in the same path of the workbook.
. 4. Close the "Transaction Report.xlsx"
D. Display message "Report created " .Name of the File & Total Records in the file
I have attached the sample files for your reference.
Look forward to hearing from you.
Regards,
Don