Hello all
I have some code below which works via the right click menu of an internal application.
Whatever is right clicked (such as company name) takes the focus to the spreadsheet and then finds this name in the excel spreadsheet and returns a piece of information back to the internal app via the msg box.
The code works well and does its job but in returning the information i need takes around 1 minute. The exact area where the process slows down is when performing the sql statement.
Is there a possibility of speeding up the retrieval? I have tried DAO but nothing gets any quicker.
I guess this is the only way of doing this too as the workbook must remain closed as its accesses via an internal app and its used only for information. Or is there another way of doing this?
Any help or suggestions much appreciated.
---------------------------------------------------------
Private Sub Checker_Click(ByVal Button As CommandBarButton, Cancel As Boolean)
Set objConnection = CreateObject("ADODB.Connection")
Set objrecordset = CreateObject("ADODB.Recordset")
mycompany = Checker.parameter
mysql = "select code from sch where proc_id='" & mycompany & "' and code_sch='SAM'"
result = PMY.INTData("COMPANY", mysql)
If IsArray(result) Then
myresult = result(1)
End If
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Y:\Temp\The_Sheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
objrecordset.Open "Select COMPANY FROM [Sheet1$] Where COMPANY='" & myresult & "'", _
objConnection
myvalue = objrecordset.Fields.Item("COMPANY").Value
MsgBox myvalue, vbOKOnly
End Sub
I have some code below which works via the right click menu of an internal application.
Whatever is right clicked (such as company name) takes the focus to the spreadsheet and then finds this name in the excel spreadsheet and returns a piece of information back to the internal app via the msg box.
The code works well and does its job but in returning the information i need takes around 1 minute. The exact area where the process slows down is when performing the sql statement.
Is there a possibility of speeding up the retrieval? I have tried DAO but nothing gets any quicker.
I guess this is the only way of doing this too as the workbook must remain closed as its accesses via an internal app and its used only for information. Or is there another way of doing this?
Any help or suggestions much appreciated.
---------------------------------------------------------
Private Sub Checker_Click(ByVal Button As CommandBarButton, Cancel As Boolean)
Set objConnection = CreateObject("ADODB.Connection")
Set objrecordset = CreateObject("ADODB.Recordset")
mycompany = Checker.parameter
mysql = "select code from sch where proc_id='" & mycompany & "' and code_sch='SAM'"
result = PMY.INTData("COMPANY", mysql)
If IsArray(result) Then
myresult = result(1)
End If
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Y:\Temp\The_Sheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
objrecordset.Open "Select COMPANY FROM [Sheet1$] Where COMPANY='" & myresult & "'", _
objConnection
myvalue = objrecordset.Fields.Item("COMPANY").Value
MsgBox myvalue, vbOKOnly
End Sub