473,485 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

RecordsetClone.RecordCount producing Invalid Argument error

Seth Schrock
2,965 Recognized Expert Specialist
I'm trying to get the record count of a subform. Based on what I found online, I should be able to use the RecordsetClone.RecordCount property to get this value. However, I get error 3001, Invalid argument when I try.

The following code works in the immediate window:
Expand|Select|Wrap|Line Numbers
  1. ?me.sfrmHosts.Form.Name
  2. sfrmHosts
This code fails with the above error:
Expand|Select|Wrap|Line Numbers
  1. ?me.sfrmHosts.Form.RecordsetClone.RecordCount
????????
(Hair being pulled out)

I originally tried with .Recordset.RecordCount, but I got the same error with that. What is wrong?
Oct 7 '14 #1
11 1696
twinnyfo
3,653 Recognized Expert Moderator Specialist
Seth,

Try the following:

Expand|Select|Wrap|Line Numbers
  1.     Dim rstClone As Recordset
  2.     Set rstClone = Me.sfrmHosts.Form.RecordsetClone
  3.     rstClone.MoveLast
  4.     Debug.Print rstClone.RecordCount
You have to declare the recordsetclone first.
Oct 8 '14 #2
Seth Schrock
2,965 Recognized Expert Specialist
I now fail on the
Expand|Select|Wrap|Line Numbers
  1. Set rst = Me.sfrmHosts.Form.RecordsetClone
line with the same error, Invalid Argument.
Oct 8 '14 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
Seth,

Where are you putting the code for this count? I just created a form/subform and it worked perfectly. I have it in the OnCurrent Event of the main form.

Does the Subform currently have a record source (I know, dumb question). This just seems strange.

Worst case, re-create the forms and copy and paste all the controls and code. Sometimes kick-starting from scratch will give different results--you know how finicky Access can be....
Oct 8 '14 #4
Seth Schrock
2,965 Recognized Expert Specialist
I have a combo box in the header of the parent form. I use it's After_Update event to run this code. The subform does have a record source (a querydef).

I'll give starting from scratch a try. Unfortunately this is a complicated form with lots of code to move :(
Oct 8 '14 #5
Seth Schrock
2,965 Recognized Expert Specialist
After starting over, I'm now getting a different error on the same line of code: Object variable or With block variable not set. I'm not using any With/End With, nor is there a variable being used. I tried it both with setting the Recordset variable and without and neither worked. This is so strange.
Oct 8 '14 #6
twinnyfo
3,653 Recognized Expert Moderator Specialist
Try this, jsut to see if we are looking in the wrong place.

Create a new form. Create another form (subform) which has a table as a record source. Don't make it fancy.

Recreate our current situation and see if the code will work. According to theory, whether you have a Table or a QueryDef, the RecordsetClone should work. But, let's see if this will work with a table. Then, maybe we can see some other light at the end of tht tunnel.
Oct 8 '14 #7
Seth Schrock
2,965 Recognized Expert Specialist
I created the simplest form/subform that I could with a button to trigger the code.
Expand|Select|Wrap|Line Numbers
  1. MsgBox Me.Hosts.Form.Recordset.RecordCount
I tried with both Parent and Child forms based on tables and on QueryDefs. Both tries worked perfectly. I guess I'm just going to have to start completely over without copying anything over and try it that way. It probably wouldn't hurt to rethink what I'm doing anyway.

So strange.
Oct 8 '14 #8
twinnyfo
3,653 Recognized Expert Moderator Specialist
Have you also tried with the RcordsetClone? (although you've just proven that the clone is not required.

I feel your pain. Obviously there is "something" going on in your form/subform that doesn't like the record counting. I am sure you have must less hair left by now....

:-/
Oct 8 '14 #9
Seth Schrock
2,965 Recognized Expert Specialist
I just tried with the RecordsetClone and it worked with the QueryDefs.

Thankfully, pulling on my hair didn't cause any to come out so I have the same number right now. We will see about later.......
Oct 8 '14 #10
twinnyfo
3,653 Recognized Expert Moderator Specialist
Any ideas what the issue was? Very strange....
Oct 8 '14 #11
Seth Schrock
2,965 Recognized Expert Specialist
I'm just guessing that the main form is corrupted. I was still using the simple test form, so I don't have anything definitive.
Oct 8 '14 #12

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

Similar topics

0
5260
by: Mara | last post by:
Hi, I have very serious problem with query in Access. I have, in my DB, a lot of forms with some buttons that I use to do query. When I press that buttons and query start I have "Invalid...
8
3356
by: Owen Jenkins | last post by:
Hello. For years I've been using the DBEngine.CompactDatabase code to make backups of backend databases. But now I've struck a baffling problem where I get an Invalid Argument error. This...
1
9119
by: shalinmangar | last post by:
Hi, I have created two javascript classes in the following way. //Script tag starts here function ClassA(textBoxID, objB) { this.textBox = document.getElementById(textBoxID); this.objB =...
1
1775
by: Eric | last post by:
When I run my script it gives error on the following line: strEmail = Right(strEmail, (Len(strEmail) - 1)) I enclose my code and the sample text file too Thanks,...
8
5888
by: matt1856 | last post by:
I have a database that I have been using for years. I installed some updates and now I get a "invalid argument" error when I try to open the database. I have tried to run the "compact and repair"...
1
1717
by: Adam G | last post by:
Ahoy. I keep getting an "Invalid Argument" error whenever I try to Make Table query in Access. The query looks fine as a Select Query but cannot be saved nor made into a Make Table query. ...
1
1623
by: mdhameed2007 | last post by:
hi this is hameed i have Lots of Query to Run in office 2000 Access Query and Invalid Argument Error is coming when i am run the Query plz help me to
1
4625
by: max.aginaga | last post by:
Hi everyone I've come across the following problem: on two different linux machines, both running python 2.5 (r25:51908), I have the same file 'd.dat'. The md5 checksums are the same. Now, on...
0
3259
by: shekharban | last post by:
Hi, Below is the raw socket program for sending routing header in ipv6 domain. My source address is fe80::21d:9ff:fe17:58c7 and destination address is fe80::21d:9ff:fe17:5d0e in the below...
0
7090
marktang
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,...
0
6960
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
7275
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...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4857
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...
0
3058
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...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
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 ...
0
247
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.