473,804 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check recordcount -table in Ms access(local)

22 New Member
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....
Feb 13 '08 #1
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
Feb 13 '08 #2
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....
Expand|Select|Wrap|Line Numbers
  1. Private Sub Process_Click()
  2. Dim rcst As New ADODB.Recordset
  3. Dim Con As New ADODB.Connection
  4. Dim rst As New ADODB.Recordset
  5.  
  6. Set Con = CurrentProject.Connection
  7.  
  8. If Frame160 = 1 Then
  9.   query1 = "select * from Table a where DMNum LIKE '" & Textboxentry & "*'"
  10.   rst.Open query1, Con, adOpenDynamic, adLockOptimistic
  11.     If Not rst.BOF And Not rst.EOF Then     'valid Record(s) exist
  12.       query1 = "select * from Table a where DMNum LIKE '" & Textboxentry & "*'"
  13.         Me.Mysubform.Form.RecordSource = query1
  14.         Form_Myform.Textboxentry = Clear
  15.         Form_Myform.Textboxentry.SetFocus
  16.         Textboxentry = ""
  17.           rst.Close
  18.     Else
  19.       MsgBox " No Records Available for this search"
  20.       Textboxentry.Text = ""
  21.         rst.Close
  22.         Call Form_Load
  23.           Exit Sub
  24.     End If
  25. ElseIf Frame160 = 2 Then
  26. ....................
  27. ................
  28. End If
  29. End Sub
P.S. - Have a look at this Link also:
How to check for an Empty Recordset
Feb 14 '08 #3
jaishu
22 New Member
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
Feb 15 '08 #4
FishVal
2,653 Recognized Expert Specialist
Hi, Jaishu.

Read ANSI Standards in String Comparisons article.

Regards,
Fish
Feb 15 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1333
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.
1
121540
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
13
10810
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.
9
2211
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;
1
5002
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
9
3779
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...
3
2400
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.
1
6134
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...
2
8099
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...
22
8440
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";
0
9572
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,...
0
10319
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
10303
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
10070
tracyyun
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...
1
7608
isladogs
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...
0
5508
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
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
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
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.