![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Help to build a Requery Hi. With second query, un error is generated: "The object objRecordset is already open" With this code is possible to requery the object "objRecordset" without clouse it? adOpenStatic = 3 adLockOptimistic = 3 adUseClient = 3 Set objConnection = CreateObject("ADODB.Connection") Set objRecordset = CreateObject("ADODB.Recordset") StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Supervisao\Descarga.mdb;Persist Security Info=False" objRecordset.CursorLocation = adUseClient objRecordset.Open "SELECT * FROM RegVag" , StrCnn ,adOpenStatic, adLockOptimistic QueryHistActuDesc="TRANSFORM IIf(IsNull(SUM(Vagonas)),0,SUM(Vagonas)) SELECT Data FROM RegVag Where Data = #"+ CarRegDataIn + "# group by Data order by Data Asc PIVOT 'P' & CodMat In ('P1','P2','P3','P4','P5','P6')" objRecordset.Open QueryHistActuDesc, StrCnn ,adOpenStatic, adLockOptimistic Set Descarga_DataGrid1.DataSource = objRecordset IF not objRecordSet.EOF then DVE(0)=CInt(objRecordSet.Fields(1).Value) DVE(1)=CInt(objRecordSet.Fields(2).Value) DVE(2)=CInt(objRecordSet.Fields(3).Value) DVE(3)=CInt(objRecordSet.Fields(4).Value) DVE(4)=CInt(objRecordSet.Fields(5).Value) DVE(5)=CInt(objRecordSet.Fields(6).Value) else DVE(0)=0 DVE(1)=0 DVE(2)=0 DVE(3)=0 DVE(4)=0 DVE(5)=0 end if QueryHistActuDesc="TRANSFORM IIf(IsNull(SUM(Paletes)),0,SUM(Paletes)) SELECT Data FROM RegVag Where Data = #"+ CarRegDataIn + "# group by Data order by Data Asc PIVOT 'P' & CodMat In ('P1','P2','P3','P4','P5','P6')" objRecordset.Open QueryHistActuDesc, StrCnn ,adOpenStatic, adLockOptimistic IF not objRecordSet.EOF then DVE(9)=CInt(objRecordSet.Fields(1).Value) DVE(10)=CInt(objRecordSet.Fields(2).Value) DVE(11)=CInt(objRecordSet.Fields(3).Value) DVE(12)=CInt(objRecordSet.Fields(4).Value) DVE(13)=CInt(objRecordSet.Fields(5).Value) DVE(14)=CInt(objRecordSet.Fields(6).Value) else DVE(9)=0 DVE(10)=0 DVE(11)=0 DVE(12)=0 DVE(13)=0 DVE(14)=0 end if objRecordset.close Thanks H |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Help to build a Requery "Henrique" <wq@xxxxxx> wrote in message news:newscache$mhr9ak$vic$1@xxxxxx Quote: > Hi. > > > With second query, un error is generated: "The object objRecordset is > already open" > > With this code is possible to requery the object "objRecordset" without > clouse it? > > adOpenStatic = 3 > adLockOptimistic = 3 > adUseClient = 3 > Set objConnection = CreateObject("ADODB.Connection") > Set objRecordset = CreateObject("ADODB.Recordset") > StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=C:\Supervisao\Descarga.mdb;Persist Security Info=False" > objRecordset.CursorLocation = adUseClient > objRecordset.Open "SELECT * FROM RegVag" , StrCnn ,adOpenStatic, > adLockOptimistic > > QueryHistActuDesc="TRANSFORM IIf(IsNull(SUM(Vagonas)),0,SUM(Vagonas)) > SELECT Data FROM RegVag Where Data = #"+ CarRegDataIn + "# group by Data > order by Data Asc PIVOT 'P' & CodMat In ('P1','P2','P3','P4','P5','P6')" > objRecordset.Open QueryHistActuDesc, StrCnn ,adOpenStatic, > adLockOptimistic > > Set Descarga_DataGrid1.DataSource = objRecordset > > IF not objRecordSet.EOF then > DVE(0)=CInt(objRecordSet.Fields(1).Value) > DVE(1)=CInt(objRecordSet.Fields(2).Value) > DVE(2)=CInt(objRecordSet.Fields(3).Value) > DVE(3)=CInt(objRecordSet.Fields(4).Value) > DVE(4)=CInt(objRecordSet.Fields(5).Value) > DVE(5)=CInt(objRecordSet.Fields(6).Value) > else > DVE(0)=0 > DVE(1)=0 > DVE(2)=0 > DVE(3)=0 > DVE(4)=0 > DVE(5)=0 > end if > > > > QueryHistActuDesc="TRANSFORM IIf(IsNull(SUM(Paletes)),0,SUM(Paletes)) > SELECT Data FROM RegVag Where Data = #"+ CarRegDataIn + "# group by Data > order by Data Asc PIVOT 'P' & CodMat In ('P1','P2','P3','P4','P5','P6')" > objRecordset.Open QueryHistActuDesc, StrCnn ,adOpenStatic, > adLockOptimistic > IF not objRecordSet.EOF then > DVE(9)=CInt(objRecordSet.Fields(1).Value) > DVE(10)=CInt(objRecordSet.Fields(2).Value) > DVE(11)=CInt(objRecordSet.Fields(3).Value) > DVE(12)=CInt(objRecordSet.Fields(4).Value) > DVE(13)=CInt(objRecordSet.Fields(5).Value) > DVE(14)=CInt(objRecordSet.Fields(6).Value) > else > DVE(9)=0 > DVE(10)=0 > DVE(11)=0 > DVE(12)=0 > DVE(13)=0 > DVE(14)=0 > end if > > objRecordset.close > > > > Thanks > > H > to issue both queries at once. Then use the NextRecordset method. http://www.w3schools.com/ADO/met_rs_nextrecordset.asp -- Joe Fawcett (MVP - XML) http://joe.fawcett.name |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| New Build | Vista hardware & devices | |||
| Powershell for Longhorn Build Build 6001 | PowerShell | |||
| Vista Build 5744 doesn't want to upgrade build 5536 | Vista installation & setup | |||
| Vista public build 5384, nerds build 5472 | Vista General | |||
| Build NO. | Vista mail | |||