Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Help to build a Requery

Reply
 
Old 11-13-2008   #1 (permalink)
Henrique


 
 

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 SpecsSystem Spec
Old 11-13-2008   #2 (permalink)
Joe Fawcett


 
 

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
>
If your not using any of the first data in the second query then one way is
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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46