Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everyone
I am trying to retrieve the data from MS Access database through ODBC query through a function given below Sub query_gen(fproject_master, fproject_master1, fproject_master2, fmptable, fmptable1, fpdetail, fpdetail1, fpdetail2, fpdetail3, fpdetail4, query1, query2, query3, query4, query5, fcycle_type direc = Worksheets("QUERY_BUILDER").Range("BH1").Valu datab = Worksheets("QUERY_BUILDER").Range("BH2").Valu ' Sheet2.Columns("A:BA").NumberFormat = "General With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( "ODBC;DSN=MS Access Database;DBQ=" + CStr(datab) + ";DefaultDir=\\phome5\common\AT\AT-Amendments;DriverId=25;"), Array("FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:= Range("A7") .Sql = Array("SELECT " & fproject_master & " " & fproject_master1 & " " & fproject_master2 & " " & fmptable & " " & fmptable1 & " " & fpdetail & " " & fpdetail1 & " " & fpdetail2 & " " & fpdetail3 & " " & fpdetail4 & " " & fcycle_type & " FROM `" & CStr(datab) & "`.M_P_Table M_P_Table, `" + CStr(datab) & "`.Cycle_Type Cycle_Type, `" & CStr(datab) + "`.P_Detail P_Detail, `" + CStr(datab) + "`.Project_Master Project_Master" & " WHERE M_P_Table.M_P_No = P_Detail.M_P_No AND M_P_Table.Project_No = " & "Project_Master.Project_No AND Cycle_Type.cycle_project=P_Detail.Serial_No" & "AND ((" & query1 & query2 & query3 & query4 & query5 & "))" FieldNames = Tru .RefreshStyle = xlInsertDeleteCell .RowNumbers = Fals .FillAdjacentFormulas = Fals .RefreshOnFileOpen = Fals .HasAutoFormat = Tru .BackgroundQuery = Tru .TablesOnlyFromHTML = Tru .Refresh BackgroundQuery:=Fals .SavePassword = Tru .SaveData = False 'Will not save the dat End Wit End Su Whenever I am trying to run this query it is giving 2 errors First it gives error on line : Sheet2.Columns("A:BA").NumberFormat = "General the error is Run-Time Error "1004" :unable to set the NumberFormat property of Range Class So I commented this line and the second error its giving type mismatch on line ..Sql = Array("SELECT " & fproject_master & " " & fproject_master1 & " " & fproject_master2 & " " & fmptable & " " & fmptable1 & " " & fpdetail & " " & fpdetail1 & " " & fpdetail2 & " " & fpdetail3 & " " & fpdetail4 & " " & fcycle_type & " FROM `" & CStr(datab) & "`.M_P_Table M_P_Table, `" + CStr(datab) & "`.Cycle_Type Cycle_Type, `" & CStr(datab) + "`.P_Detail P_Detail, `" + CStr(datab) + "`.Project_Master Project_Master" & " WHERE M_P_Table.M_P_No = P_Detail.M_P_No AND M_P_Table.Project_No = " & "Project_Master.Project_No AND Cycle_Type.cycle_project=P_Detail.Serial_No" & "AND ((" & query1 & query2 & query3 & query4 & query5 & "))" It was not giving this error earlier. Its all of a sudden. What could be the possible reason of this sudden appearance of error TI Shilp |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem with Web Query | Excel Discussion (Misc queries) | |||
Query Problem | Excel Worksheet Functions | |||
Problem with MS Query - can't edit query | Excel Discussion (Misc queries) | |||
Query problem | Excel Discussion (Misc queries) | |||
Problem with .Background Query option of ODBC Query | Excel Programming |