473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual Basic Not Waiting for Query to fully evaluate???

Hello all,

I am using Visual Basic to open a saved query and then save
information in the query to an array for later use. The problem is
that the same query shows different results when opened directly vs.
when opened by Visual Basic. It is as if Visual Basic is not letting
the query fully evaluate before processing records.

The query is a subtotal query that contains several criteria set up as
"where" in the group-by box. Most of the criteria are based on one
table, one criteria is based on a second joined table. When the query
is opened directly this last criteria is correctly evaluated and the
proper records are shown. When opened in VB it is as if this criteria
did not exist. The query otherwise shows correct information except
it includes records that should not be there based on the last
criteria.

Is there a way to force visual basic to wait until a query is fully
opened before executing code that uses the resulting records. Or is
there something else that I am missing.

Any help would be greatly appreciated.

Thanks,

Vince

Partial code Follows---------------------------------
Public aWork(10) as Integar

Sub LoadWorkArray(W orkQuery as string) 'WorkQuery = query name
Dim WorkLastRecord as Integar
Dim X as Integar

Set SLWork = New ADODB.Recordset

SLWork.Open WorkQuery, CurrentProject. Connection, adOpenKeyset,
adLockOptimisti c

WorkLastRecord = SLWork.RecordCo unt

ReDim aWork(WorkLastR ecord + 1)

With SLWork
.MoveFirst
For X = 1 To WorkLastRecord
aWork(X) = ![Attending Number]
.MoveNext
Next X
.Close
End With

End sub
Dec 28 '07 #1
6 2554
I'm no expert but would it not be worth adding a line before you go to the
beginning of the recordset to go to the end of the recordset. I think this
would force the query to be fully executed before evaluating the values
returned from it.

Something like:

With SLWork
.MoveLast
.MoveFirst
For X = 1 To WorkLastRecord
aWork(X) = ![Attending Number]
.MoveNext
Next X
.Close
End With

Regards,

Mark

"Vince" <VA*********@ya hoo.comwrote in message
news:46******** *************** ***********@e10 g2000prf.google groups.com...
Hello all,

I am using Visual Basic to open a saved query and then save
information in the query to an array for later use. The problem is
that the same query shows different results when opened directly vs.
when opened by Visual Basic. It is as if Visual Basic is not letting
the query fully evaluate before processing records.

The query is a subtotal query that contains several criteria set up as
"where" in the group-by box. Most of the criteria are based on one
table, one criteria is based on a second joined table. When the query
is opened directly this last criteria is correctly evaluated and the
proper records are shown. When opened in VB it is as if this criteria
did not exist. The query otherwise shows correct information except
it includes records that should not be there based on the last
criteria.

Is there a way to force visual basic to wait until a query is fully
opened before executing code that uses the resulting records. Or is
there something else that I am missing.

Any help would be greatly appreciated.

Thanks,

Vince

Partial code Follows---------------------------------
Public aWork(10) as Integar

Sub LoadWorkArray(W orkQuery as string) 'WorkQuery = query name
Dim WorkLastRecord as Integar
Dim X as Integar

Set SLWork = New ADODB.Recordset

SLWork.Open WorkQuery, CurrentProject. Connection, adOpenKeyset,
adLockOptimisti c

WorkLastRecord = SLWork.RecordCo unt

ReDim aWork(WorkLastR ecord + 1)

With SLWork
.MoveFirst
For X = 1 To WorkLastRecord
aWork(X) = ![Attending Number]
.MoveNext
Next X
.Close
End With

End sub

Dec 28 '07 #2
On Dec 28, 6:14*pm, "Mark" <mreed1...@btin ternet.comwrote :
I'm no expert but would it not be worth adding a line before you go to the
beginning of the recordset to go to the end of the recordset. I think this
would force the query to be fully executed before evaluating the values
returned from it.

Something like:

With SLWork
* * .MoveLast
* * .MoveFirst
* * For X = 1 To WorkLastRecord
* * * * aWork(X) = ![Attending Number]
* * * *.MoveNext
* * Next X
* * .Close
*End With

Regards,

Mark

"Vince" <VArgenzi...@ya hoo.comwrote in message

news:46******** *************** ***********@e10 g2000prf.google groups.com...
Hello all,
I am using Visual Basic to open a saved query and then save
information in the query to an array for later use. *The problem is
that the same query shows different results when opened directly vs.
when opened by Visual Basic. *It is as if Visual Basic is not letting
the query fully evaluate before processing records.
The query is a subtotal query that contains several criteria set up as
"where" in the group-by box. *Most of the criteria are based on one
table, one criteria is based on a second joined table. *When the query
is opened directly this last criteria is correctly evaluated and the
proper records are shown. *When opened in VB it is as if this criteria
did not exist. *The query otherwise shows correct information except
it includes records that should not be there based on the last
criteria.
Is there a way to force visual basic to wait until a query is fully
opened before executing code that uses the resulting records. *Or is
there something else that I am missing.
Any help would be greatly appreciated.
Thanks,
Vince
Partial code Follows---------------------------------
Public aWork(10) as Integar
Sub LoadWorkArray(W orkQuery as string) *'WorkQuery = query name
Dim WorkLastRecord as Integar
Dim X as Integar
Set SLWork = New ADODB.Recordset
SLWork.Open WorkQuery, CurrentProject. Connection, adOpenKeyset,
adLockOptimisti c
WorkLastRecord = SLWork.RecordCo unt
ReDim aWork(WorkLastR ecord + 1)
With SLWork
* *.MoveFirst
* *For X = 1 To WorkLastRecord
* * * *aWork(X) = ![Attending Number]
* * * .MoveNext
* *Next X
* *.Close
End With
End sub- Hide quoted text -

- Show quoted text -
Hello Lyle,

You got it with using an "*" vs "%". The query was using a Not Like
"*string*" expression. Changed it to use % instead and now it works.
You do not know how long I have been looking at everything but the
string. While the query opens normally from Access the ADODB
apparently totally ignores an expression that uses an *.

Thanks for everybody's help.

Vince
Dec 28 '07 #3
Vince <VA*********@ya hoo.comwrote in
news:38******** *************** ***********@e4g 2000hsg.googleg roups.com
:
You got it with using an "*" vs "%". The query was using a Not
Like "*string*" expression. Changed it to use % instead and now
it works. You do not know how long I have been looking at
everything but the string. While the query opens normally from
Access the ADODB apparently totally ignores an expression that
uses an *.
Why are you using ADO? Makes no sense to me.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 29 '07 #4
On Dec 28 2007, 8:23*pm, "David W. Fenton"
<XXXuse...@dfen ton.com.invalid wrote:
Vince <VArgenzi...@ya hoo.comwrote innews:38****** *************** *************@e 4g2000hsg.googl egroups.com
:
You got it with using an "*" vs "%". *The query was using a Not
Like "*string*" expression. *Changed it to use % instead and now
it works. You do not know how long I have been looking at
everything but the string. *While the query opens normally from
Access the ADODB apparently totally ignores an expression that
uses an *.

Why are you using ADO? Makes no sense to me.

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/
Hi David,

It was a way of opening a query inside VB to populate an array. I
also tried opening the query as the DAO recordset type of object and
got the same results. I had done this in a number of other queries
but this is the first one I had a problem with. I would be open to a
better approach.

Thanks,

Vince
Jan 1 '08 #5
On Jan 1, 4:30*pm, Vince <VArgenzi...@ya hoo.comwrote:
On Dec 28 2007, 8:23*pm, "David W. Fenton"

<XXXuse...@dfen ton.com.invalid wrote:
Vince <VArgenzi...@ya hoo.comwrote innews:38****** *************** *************@e 4g2000hsg.googl egroups.com
:
You got it with using an "*" vs "%". *The query was using a Not
Like "*string*" expression. *Changed it to use % instead and now
it works. You do not know how long I have been looking at
everything but the string. *While the query opens normally from
Access the ADODB apparently totally ignores an expression that
uses an *.
Why are you using ADO? Makes no sense to me.
--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/

Hi David,

It was a way of opening a query inside VB to populate an array. *I
also tried opening the query as the DAO recordset type of object and
got the same results. *I had done this in a number of other queries
but this is the first one I had a problem with. *I would be open to a
better approach.

Thanks,

Vince- Hide quoted text -

- Show quoted text -
Excuse me, I meant to say I had tried opening the recordset as its
default object type and got the same results.
Jan 1 '08 #6
Vince <VA*********@ya hoo.comwrote in
news:58******** *************** ***********@e50 g2000hsh.google groups.co
m:
Excuse me, I meant to say I had tried opening the recordset as
its default object type and got the same results.
The default object type depends on what references your database
has. Which references you get by default depends on which version of
Access you created the MDB with.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jan 1 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4146
by: Robin Powers | last post by:
PROCESS CONTROLS/VISUAL BASIC PROGRAMMERS SALARY: TO $100,000 LOCATION: LOS ANGELES AREA Our Client has recently acquired process automation systems used to monitor and control their asphalt drum operations. The architecture for this system is an Allen-Bradley SLC 5/04 PLC talking to
0
1010
by: francisl | last post by:
I'm quite new to code with thread. I found that it is useful for graphical programming, but now I would like to add this to some of my program. I tried something but I think I'll have to read a little more on it. What my program do, is to query a microsoft AD to find all servers in it, then it query all of those servers for some information on their registry keys. In fact, everything work well, but the whole process take more than 30...
3
3044
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going on? I have tested this extensively and can say for certain that installing this hot fix is what has caused the performance problem. I just don't know why or how to fix it. Brian Oster
2
2532
by: Norm | last post by:
I have run into problems from time to time (and this is one of those times) using visual basic to access an external database and perform a basic select from statement. When the table is extremely large and performance low, the application freezes. It seems that it is timing out. Recently I was trying to hit an oracle database and got the same problem. In this case, I query a view. When I query a view on a large database, the progam...
26
10849
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio compiles the same solution much faster (about 10 seconds for the first project). My home computer is only marginally faster than the one I have at the office (P4 2.53 vs. P4 2.4, same amount of RAM). On the slow machine, the CPU usage is very low,...
3
2957
by: Omar | last post by:
Hi Developers, I am trying to access an Excel data file through a VB.Net application. I have the following code: =================================== VB.Net Code =================== Dim sSqlString = "" Dim rCount As Integer = 0 Dim sDataSet As New DataSet() sSqlString = "Select * From "
1
4550
by: praful pathak | last post by:
i i am praful pathak,porbandar i want to develop my own cross tab report in visual basic 6 i know what developed query from ms access but how to coded in visual basic in designing time and how to construct it plz solve this problem query from ms access TRANSFORM Sum(Temp.SumOfS_Qty) AS SumOfSumOfS_Qty
19
1794
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. Threading is a new concept for me to implement. Here is my problem. I have a system that receives xml files and records their file locations in a database. I can potentially receive thousands,
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.