VBA to count records on Access

yncip

New Member
Joined
Jul 18, 2014
Messages
9
Hi all, I have a problem when running this vba code:
Code:
SetRS1 "Select * From Q_SdbK Where Sh_No Between '" & (ship1.Value) & "' AND '" & (ship2.Value) & "'"
'Rs1.MoveNext
While Not Rs1.EOF
a = Rs1(0)
    SetRS2 "Select * From Q_PrintKA Where Shp_No ='" & (a) & "'"
[B]    end = DCount("*", "Q_PrintKA", "Shp_No ='" & (a) & "'")
[/B]
when it reached the bold part, the running will stop and show this error
"Run-time error '2950':
Reserved Error"

But the error won't come if open the Access file while running the code.

Anyone could help me with this problem?

Thank you
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,191,532
Messages
5,987,127
Members
440,080
Latest member
drhorn4908

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top