Hi all,
I am in the process of developing a small Access application. i have the table locally in Access and I am using the following code to get the recordcount ( or to check if any record exists), but when i check for rst.eof condition, it is always true..but when i actually run the query i see, many rows returned, i m not clear about how to specify the connection parameter with the recordset, as i m using the tables locally, but i think something is wrong with the ADODB connection???
[code starts here]
Private Sub Process_Click()
Dim rcst As New ADODB.Recordset
Dim Con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set Con = CurrentProject.Connection
If Frame160 = 1 Then
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
rst.Open query1, Con, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
MsgBox " No Records Available for this search"
Textboxentry.Text = ""
rst.Close
Call Form_Load
Exit Sub
Else
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
Me.Mysubform.Form.RecordSource = query1
Form_Myform.Textboxentry= Clear
Form_Myform.Textboxentry.SetFocus
Textboxentry= ""
rst.Close
End If
ElseIf Frame160 = 2 Then
....................
................
End If
End Sub
[code ends here]
Is there anyother way that i can check for recordcount for the Query1?
Any help is highly appreciated.
Thanks so much in advance....
4 2625
Hi, jaishu.
Just two suggestions. - get a runtime value of query1 variable and try to execute in Query builder
- try to use "%" wildcard instead of "*"
Regards,
Fish
Hi all,
I am in the process of developing a small Access application. i have the table locally in Access and I am using the following code to get the recordcount ( or to check if any record exists), but when i check for rst.eof condition, it is always true..but when i actually run the query i see, many rows returned, i m not clear about how to specify the connection parameter with the recordset, as i m using the tables locally, but i think something is wrong with the ADODB connection???
[code starts here]
Private Sub Process_Click()
Dim rcst As New ADODB.Recordset
Dim Con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set Con = CurrentProject.Connection
If Frame160 = 1 Then
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
rst.Open query1, Con, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
MsgBox " No Records Available for this search"
Textboxentry.Text = ""
rst.Close
Call Form_Load
Exit Sub
Else
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
Me.Mysubform.Form.RecordSource = query1
Form_Myform.Textboxentry= Clear
Form_Myform.Textboxentry.SetFocus
Textboxentry= ""
rst.Close
End If
ElseIf Frame160 = 2 Then
....................
................
End If
End Sub
[code ends here]
Is there anyother way that i can check for recordcount for the Query1?
Any help is highly appreciated.
Thanks so much in advance....
-
Private Sub Process_Click()
-
Dim rcst As New ADODB.Recordset
-
Dim Con As New ADODB.Connection
-
Dim rst As New ADODB.Recordset
-
-
Set Con = CurrentProject.Connection
-
-
If Frame160 = 1 Then
-
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry & "*'"
-
rst.Open query1, Con, adOpenDynamic, adLockOptimistic
-
If Not rst.BOF And Not rst.EOF Then 'valid Record(s) exist
-
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry & "*'"
-
Me.Mysubform.Form.RecordSource = query1
-
Form_Myform.Textboxentry = Clear
-
Form_Myform.Textboxentry.SetFocus
-
Textboxentry = ""
-
rst.Close
-
Else
-
MsgBox " No Records Available for this search"
-
Textboxentry.Text = ""
-
rst.Close
-
Call Form_Load
-
Exit Sub
-
End If
-
ElseIf Frame160 = 2 Then
-
....................
-
................
-
End If
-
End Sub
P.S. - Have a look at this Link also: How to check for an Empty Recordset
Hi Fishval and Adezii,
Thank you very much, yes it works now.. i used both your techniques
used " % " instead of " * " when checking EOF condition, and for requery(when record exists to populate values) used the ' * '.
It worked, but any reason why * did not work for EOF/BOF checking and only % worked?????
BUT THANK YOU SO MUCH FOR CORRECTING THE FLOW OF CODE,
Really appreciate your help!!!
Bye,
Jaishu
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Colin J. Williams |
last post by:
I have material on a local PC which I upload to a web server.
I would like to use webchecker to check both the local linkage and that
at the remote server.
All works well when I check the...
|
by: jiing |
last post by:
Now let me describe what I have done and my purpose:
Originally, I want to user ports to install phpBB
But I found that phpBB doesn't support mysql 5.x (but the ports
installed mySQL 5.0.0...
|
by: Niki Kovacs |
last post by:
Hi,
I'm an Austrian writer living in Montpezat (South France). I just installed
a local W3C validator on my machine (Slackware 10.1, local Apache server).
It's accessible as...
|
by: Stefan Turalski \(stic\) |
last post by:
Hi,
I done sth like this:
for(int i=0; i<10; i++) {...}
and after this local declaration of i variable I try to inicialize
int i=0;
|
by: BuddyWork |
last post by:
Hello,
I need to know how I can check if the drives on my machine
are network drives and local drives via the .Net framework.
For example my PC has the following drives
C: Local
D: Local
N:...
|
by: Sameh Ahmed |
last post by:
Hello there
Is there a way through dotNet to check if a certain user is a member of a
specific group?
I use ADSI to get the memberships of the user then compare them to the group
I want to check,...
|
by: Indiresh |
last post by:
Hi all,
I have a problem downloading web pages to my local system. I am using the
HttpebRequest class to query a web site and get the response from the same.
UndNow, when i asy a web page, all...
|
by: orp |
last post by:
We've been struggling on how to determine if a local user is already in a
local group. We have code (C#) that creates a local user, if the user
doesn't already exist. And, we have code (C#) that...
|
by: Jerad Rose |
last post by:
I have a fairly simple C# console app which copies files from a network
folder to a local folder. When the app resides on my local C: drive, it
runs just fine. However, when the app resides on a...
|
by: Laura T. |
last post by:
In the following example, c# 2.0 compiler says that a3 and ret are used
before assigned.
as far as I can see, definite assignment is made.
If I add
finally
{
ret = true;
a3 = "b3";
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |