Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some questions - VBA code

0 views
Skip to first unread message

Abay

unread,
Dec 13, 2009, 1:23:45 AM12/13/09
to
I have been asked to make changes to a data base at work .. I am learning
Access 2007 as I go along, and while I understand a lot of the VBA code (the
simplest part), I am having a problem with the following:

(1) Dim RCount As Integer, i As Integer, MOrd As Integer

RCount = DCount("*", "Summary Month Query", "SIndex =" & [SIndex]) / 10
'database setup for 10 Yrs

Hrs_Calc (RCount)

i = 1

Month_subform.SetFocus

DoCmd.GoToRecord , , acFirst ... does this go to the first record in a
table?

For i = 1 To (Date - 1)

DoCmd.GoToRecord , , acNext

Next i

VacTotal = (Vacation * (Date - 1)) + Bank_Hrs_CO + summBHrs 'til end of
last month

In particular I don't understand the "Rcount = Dcount ... " statement .. It
looks like it is running a query a no of times, but I don't understand what
"*" means in the statement.

My assumeption is that then the Sub routine Hrs_calc is performed the no of
times reflected by the value of Rcunt?

(2) where can I look up the meaning of an error code eg 2950

Your help would be most appreciate.

Thanks

Ba arc


Alex Dybenko

unread,
Dec 13, 2009, 2:28:42 AM12/13/09
to
Hi,

(1) RCount = DCount("*", "Summary Month Query", "SIndex =" & [SIndex]) / 10

DCount returns number of records in query Summary Month Query for certain
SIndex

(2) You can lookup here:
http://accessblog.net/2008/02/microsoft-access-error-number-and-error.html
http://www.dbforums.com/microsoft-access/1279658-list-access-error-codes.html
http://www.e-tech.ca/001-AllAccessErrors0.ASP


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

"Abay" <ab...@aol.com> wrote in message
news:OJ5fRz7e...@TK2MSFTNGP02.phx.gbl...

Abay

unread,
Dec 13, 2009, 11:13:24 AM12/13/09
to
Thank you Alex for your reply, which is very helpful .. It is great to have
the links for error numbers.

Also to know what the Rcount statement means ... but I am still a little
puzzled as to what the "*" part of it means? Does it mean "return the
results of the query as a record count?

Many thanks again

Ba arc

"Alex Dybenko" <ale...@PLEASE.cemi.NO.rssi.SPAM.ru> wrote in message
news:Oc9OpX8e...@TK2MSFTNGP06.phx.gbl...

Jim Evans

unread,
Dec 13, 2009, 12:01:52 PM12/13/09
to
The * is a wildcard. He is saying, basically, Select "the entire record" in
"SummaryMonthlyQuery" Where the record meets the criteria of "SIndex =" &
[SIndex] and then dividing that number by 10. The RCount is just a variable
to which he is assigning the value of the DCount() function.

Using the wildcard is more efficient in a DCount than selecting a particular
field in the query, especially if the field selected is not indexed.

The RCount variable makes life easier...he doesn't need to rewrite the
entire DCount function each time he needs to use it's value, he uses the
variable which contains the value (number) he wants to refer to or use in
further calculations.

Jim

"Abay" <ab...@aol.com> wrote in message

news:ur3Kx8Af...@TK2MSFTNGP05.phx.gbl...

Abay

unread,
Dec 13, 2009, 4:33:26 PM12/13/09
to
Many thanks Jim ... this really helps my understanding, and now I many the
required changes.

Abay


"Jim Evans" <j...@microsoftdiscussions.com> wrote in message
news:%23fFO5XB...@TK2MSFTNGP05.phx.gbl...

0 new messages