473,395 Members | 1,783 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,395 software developers and data experts.

Run-Time error 2001

2
Heya.

I'm having a problem with a specific Report Routine in Access 2003. I've browsed the forums for advice but I'm still not able to identify why I'm getting this error.

Here is the Sub code:
Expand|Select|Wrap|Line Numbers
  1. Dim rs As Recordset, month, rank, control, partner, strSQL
  2.     'Retrieve current month's top 5 Point Partners
  3.     'this recordset retrieves two fields, (0) Partner Name and (1) Total Points
  4.     Set rs = CurrentDb.OpenRecordset("qryTop5")
  5.     rs.MoveFirst
  6.     'If query operation was succesful, format report controls
  7.     If Not rs.EOF Then
  8.         'Retrieve Total Points for last month's Top5 partners for previous 12 months
  9.         For month = 1 To 12 Step 1
  10.             For rank = 1 To 5 Step 1
  11.                 'Define which label's caption should be modified according to Month and Rank
  12.                 If month > 9 Then
  13.                     control = "lblParceirosP" & rank & month
  14.                 Else
  15.                     control = "lblParceirosP" & rank & "0" & month
  16.                 End If
  17.                 'Query only includes Top5 partners' points for last month
  18.                 'the previous months' points are calculated by DSum
  19.                 If month = 1 Then
  20.                     'Check for the possibility of having less than 5 partners for last month
  21.                     If rs.EOF Then Exit For
  22.                     Report_rptMensalMIS.Controls("lblParceiro" & rank).Caption = rs(0).Value
  23.                     Report_rptMensalMIS.Controls(control).Caption = Format(rs(1).Value / 1000, "##,##0")
  24.                     rs.MoveNext
  25.                 'Calculate partner's points for previous months
  26.                 Else
  27.                     'Define which partner corresponds to the current Rank
  28.                     partner = Report_rptMensalMIS.Controls("lblParceiro" & rank).Caption
  29.                     'Error occurs here
  30.                     Report_rptMensalMIS.Controls(control).Caption = Format(DSum("[TOTAL POINTS]", "tblTROCAS", "[Partner Name] = '" & partner & "' AND [DATA DO RELATORIO] = #" & CStr(Format(DateAdd("m", -month, Date), "mm/""01""/yyyy")) & "#") / 1000, "##,##0")
  31.                 End If
  32.             Next rank
  33.         Next month
  34.     End If
  35. End Sub
  36.  
As commented above, error occurs at line 29.

Can anyone shed some light on this, please?

Thanks in advance,
Matt
Oct 5 '07 #1
2 2437
JKing
1,206 Expert 1GB
Test your DSUM() logic to ensure that your criteria is producing a valid product. It's possible you are returning a null which in turn could be the problem.
Oct 5 '07 #2
mhprol
2
Hi JKing, thanks for your reply.

I had already tried debugging the code function by function, it all worked out up to DSum, hence the whole confusion.

Oddly enough, I turned off my PC on friday, went home, and sure as the sun shall rise the report was fully functional by monday morning, all on its own.

Thanks for your advice though, wish I could tell you what the solution was but I guess I'll leave that up to Microsoft's Reboot Factor.

-Matt
Oct 11 '07 #3

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

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
19
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...
0
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...

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.