I have this code working. But I can only get the query to load the data into a listbox. Does anyone know how I can get it directly into a table(tblTest)? I have tried putting "Inset into tblTest *" at the beginning of the SQL string. It does not cause an error but it does not load the data into the table.
Thank you very much.
-------------------------------------------------------------------------------------------------------------------
[CODE=vb]Private Sub buttonLoad3_Cli ck()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim sSQL As String
Set dbs = CurrentDb
Set qdf = dbs.CreateQuery Def("qryTest")
strSelect = "SELECT state_code, xxx, year, qtr "
strFrom = "FROM production_db.d bo.sy_test sy_test "
strWhere = "WHERE (state_code='88 ') AND"
strWhere = strWhere & " (xxx='123456789 0') AND "
strWhere = strWhere & " (year=2007) AND "
strWhere = strWhere & " (qtr=2)"
sSQL = strSelect & strFrom & strWhere
qdf.SQL = sSQL
qdf.Connect = "ODBC;DSN=Sybas e System 11;UID=YYYY;PWD =password;srvr= production;Data base=production _db"
Me.listTest.Row Source = "qryTest"
Me.listTest.Req uery
DoCmd.DeleteObj ect acQuery, "qryTest"
End Sub [/CODE]
-------------------------------------------------------------------------------------------------------------------
Thank you very much.
-------------------------------------------------------------------------------------------------------------------
[CODE=vb]Private Sub buttonLoad3_Cli ck()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim sSQL As String
Set dbs = CurrentDb
Set qdf = dbs.CreateQuery Def("qryTest")
strSelect = "SELECT state_code, xxx, year, qtr "
strFrom = "FROM production_db.d bo.sy_test sy_test "
strWhere = "WHERE (state_code='88 ') AND"
strWhere = strWhere & " (xxx='123456789 0') AND "
strWhere = strWhere & " (year=2007) AND "
strWhere = strWhere & " (qtr=2)"
sSQL = strSelect & strFrom & strWhere
qdf.SQL = sSQL
qdf.Connect = "ODBC;DSN=Sybas e System 11;UID=YYYY;PWD =password;srvr= production;Data base=production _db"
Me.listTest.Row Source = "qryTest"
Me.listTest.Req uery
DoCmd.DeleteObj ect acQuery, "qryTest"
End Sub [/CODE]
-------------------------------------------------------------------------------------------------------------------
Comment