473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Debug Run-Time Error

On a filter form, I have three search criteria. When i click the button to "Clear Selection", I get a 'Run-time error '3021 - No current record' if any one of the criteria has not been selected. So for example, if I have Country and Packaging selected but not Technology and i want to clear all the filters, then the RunTime error comes up. What am I missing in the code?

Here is what i have for the code so far:

Private Sub cmdDeSelectAll_Click()
Dim rsCountryDest As DAO.Recordset
Dim rsTechnologyDest As DAO.Recordset
Dim rsPackagingDest As DAO.Recordset

'Clear all Country filters

Set rsCountryDest = Me.Lst_Countries_Dest.Recordset
rsCountryDest.MoveFirst

Do While Not rsCountryDest.EOF
rsCountryDest.Edit
rsCountryDest!InSelectedList = False
rsCountryDest.Update
rsCountryDest.MoveNext
Loop

Me.Lst_Countries_Source.Requery
Me.Lst_Countries_Dest.Requery
rsCountryDest.Close

'Clear all Technology filters

Set rsTechnologyDest = Me.Lst_Technology_Dest.Recordset
rsTechnologyDest.MoveFirst

Do While Not rsTechnologyDest.EOF
rsTechnologyDest.Edit
rsTechnologyDest!InSelectedList = False
rsTechnologyDest.Update
rsTechnologyDest.MoveNext
Loop

Me.Lst_Technology_Source.Requery
Me.Lst_Technology_Dest.Requery
rsTechnologyDest.Close

'Clear all Packaging filters

Set rsPackagingDest = Me.Lst_Packaging_Dest.Recordset
rsPackagingDest.MoveFirst

Do While Not rsPackagingDest.EOF
rsPackagingDest.Edit
rsPackagingDest!InSelectedList = False
rsPackagingDest.Update
rsPackagingDest.MoveNext
Loop

Me.Lst_Packaging_Source.Requery
Me.Lst_Packaging_Dest.Requery
rsPackagingDest.Close

End Sub

Thanks for the help in advance!
Jun 14 '07 #1
2 1688
puppydogbuddy
1,923 Expert 1GB
On a filter form, I have three search criteria. When i click the button to "Clear Selection", I get a 'Run-time error '3021 - No current record' if any one of the criteria has not been selected. So for example, if I have Country and Packaging selected but not Technology and i want to clear all the filters, then the RunTime error comes up. What am I missing in the code?

Here is what i have for the code so far:

Private Sub cmdDeSelectAll_Click()
Dim rsCountryDest As DAO.Recordset
Dim rsTechnologyDest As DAO.Recordset
Dim rsPackagingDest As DAO.Recordset

'Clear all Country filters

Set rsCountryDest = Me.Lst_Countries_Dest.Recordset
rsCountryDest.MoveFirst

Do While Not rsCountryDest.EOF
rsCountryDest.Edit
rsCountryDest!InSelectedList = False
rsCountryDest.Update
rsCountryDest.MoveNext
Loop

Me.Lst_Countries_Source.Requery
Me.Lst_Countries_Dest.Requery
rsCountryDest.Close

'Clear all Technology filters

Set rsTechnologyDest = Me.Lst_Technology_Dest.Recordset
rsTechnologyDest.MoveFirst

Do While Not rsTechnologyDest.EOF
rsTechnologyDest.Edit
rsTechnologyDest!InSelectedList = False
rsTechnologyDest.Update
rsTechnologyDest.MoveNext
Loop

Me.Lst_Technology_Source.Requery
Me.Lst_Technology_Dest.Requery
rsTechnologyDest.Close

'Clear all Packaging filters

Set rsPackagingDest = Me.Lst_Packaging_Dest.Recordset
rsPackagingDest.MoveFirst

Do While Not rsPackagingDest.EOF
rsPackagingDest.Edit
rsPackagingDest!InSelectedList = False
rsPackagingDest.Update
rsPackagingDest.MoveNext
Loop

Me.Lst_Packaging_Source.Requery
Me.Lst_Packaging_Dest.Requery
rsPackagingDest.Close

End Sub

Thanks for the help in advance!
In each of the recordsets, you are doing a moveFirst without checking for RecordCount <> 0 , or alternatively, that .EOF or .BOF is not true.

See item #3 on the following link entitled VBA Traps Working With Recordsets
http://allenbrowne.com/ser-29.html
Jun 14 '07 #2
Thank you very much! It worked!
Jun 14 '07 #3

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

Similar topics

2
by: abcd | last post by:
I have an asp pages which uses ActibeX dll and Exe written in in VB and VC++. I want to debug the components from asp page. When the asp page is run I should be able to get the breakpoint in my VB...
1
by: Sam Kong | last post by:
Hello! I am using VC# 2005 Express Beta. DEBUG flag is not automatically set when I run at debug mode #if DEBUG //... #endif
7
by: Wysiwyg | last post by:
Is there any way besides adding a specific debug command line argument for the project to tell if an application is running in debug mode? Thanks! Bill
6
by: Alpha | last post by:
Hi, I'm fixing a bug in an application and need to step thru the appl to find where it's occuring. The main project includs 33 other projects each having a .resx file in it. When I step through it...
6
by: Brian Henry | last post by:
I am trying to tell if my site is running as a debug build or not in asp.net 1.1 you could say #IF DEBUG DO SOMETHING HERE #ENDIF but in ASP.NET 2.0 it seems not to work anymore... why...
3
by: Rena | last post by:
Hi all, I have created a app. project and a library which will be used by the main project, however i do not know how to get into debug mode inside the library, although break point is set. is...
10
by: Brett | last post by:
For some reason when I step into the code below, it jumps out on the second iteration at the line I have marked below. Nothing else happens - no errors. Dim tcpClient As New...
3
by: Irfan | last post by:
hi, All After using the 'build' i try to run the exe form bin folder, and it works fine. However, when i run it form debug folder it gives me a 'filenotFoundException'. Can anybody suggest why...
5
by: blackjack2150 | last post by:
Hi. This one is really strange and annoying. The main method of a Windows Application: static void Main(string args) { Application.EnableVisualStyles();...
3
by: =?Utf-8?B?bG10dGFn?= | last post by:
We have developed a number of different applications (ASP.NET web site, Windows services, DLLs, Windows forms, etc.) in C# 2.0. We have developed and unit tested all these applications/components...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.