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.Connectio n
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, adLockOptimisti c
If rst.EOF = True Then
MsgBox " No Records Available for this search"
Textboxentry.Te xt = ""
rst.Close
Call Form_Load
Exit Sub
Else
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
Me.Mysubform.Fo rm.RecordSource = query1
Form_Myform.Tex tboxentry= Clear
Form_Myform.Tex tboxentry.SetFo cus
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 2652 FishVal 2,653
Recognized Expert Specialist
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
ADezii 8,834
Recognized Expert Expert
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.Connectio n
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, adLockOptimisti c
If rst.EOF = True Then
MsgBox " No Records Available for this search"
Textboxentry.Te xt = ""
rst.Close
Call Form_Load
Exit Sub
Else
query1 = "select * from Table a where DMNum LIKE '" & Textboxentry& "*'"
Me.Mysubform.Fo rm.RecordSource = query1
Form_Myform.Tex tboxentry= Clear
Form_Myform.Tex tboxentry.SetFo cus
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 remote server: http://www3.sympatico.
.... The URL for the index.html.
However, only the index.html is read when using: file:C:\\Python23/
.... The URL for the index.html.
|
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 alpha)
so I deinstall mysql5-server and mysql5-client
And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by
ports
but now , mysql is not workable
|
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 http://w3c-validator, because I'm on dialup and I want
to check pages offline.
Unfortunately, URL upload won't work, because the validator doesn't accept
any URL's beginning with http://localhost.
|
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: Network
S: Network
| |
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, but this way the user has to be a member of this group
directly and if he is a member of a group that is a member of that group he
will not be considered a member of the group I am checking although he is
implicitly.
so basically what I need is...
|
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 the images and support files such as JS
file, CSS files are also in picture.
I want to store the response stream to the local drive, say something like
"C:\Temp", and i want all the images and CSS files to be stored to this local
path.
|
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 creates a local group,
if the group doesn't already exist. Both of these work fine.
Now, we need to check whether the local user is already in the local group
or not. We have code (C#) that adds the local user to the local group, but
we...
|
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 network drive, copying
the same files from the same source drive and to the same destination drive,
it gives me the following exception:
System.Security.SecurityException: Request for the permission of type...
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |