473,398 Members | 2,404 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,398 software developers and data experts.

problem with dcount function in my code

sir,
i am struggling with a problem in my code.The code is

Dim subcode as Variant,intnoofsubquestions(4) as integer,i as integer

subcode = Array("ma","phy","che","ece")
'Msgbox myArray(2) is giving che .up to here no problem
the next line is
For i= 0 to 3
intnoofsubquestions(i)=Dcount("*","tablename","[subcode] = 'subcode(i)' ")
...........It is not taking subcode(0) as ma when i=0. not getting noofsubquestions from table. when i=1,2,3 also like that problem
when i write in Dcount function "[subcode]='ma' " then i am getting.
how to do this
please help me
thanks in advance
Apr 3 '07 #1
5 1538
Rabbit
12,516 Expert Mod 8TB
What this does is tell it to count if [subcode] is equal to the text subcode(i).
Expand|Select|Wrap|Line Numbers
  1. Dcount("*","tablename","[subcode] = 'subcode(i)' ")
What you want, assuming that subcode is numeric, is:
Expand|Select|Wrap|Line Numbers
  1. Dcount("*","tablename","[subcode] = " & subcode(i))
Apr 3 '07 #2
dim subcode as variant,i as integer,intAvailablesubQuestions()as integer
subcode = Array("ma", "phy", "che", "ece")
for i=0 to 3
intAvailablesubQuestions(i) = DCount("*", "tblexam", "[subcode] = 'ma'")
with the above line i am getting no. of questions.
But in my code
intAvailablesubQuestions(i) = DCount("*", "tblexam", "[subcode] = " & subcode(i))
with the next line i am not getting no. of questions. it is giving no. of questions as 0.
please help me.
Apr 4 '07 #3
Rabbit
12,516 Expert Mod 8TB
That's for numeric variables, if you're looking at a text value, you want:
Expand|Select|Wrap|Line Numbers
  1. Dcount("*","tablename","[subcode] = '" & subcode(i) & "'")
Apr 4 '07 #4
thank u that is working.
But
Expand|Select|Wrap|Line Numbers
  1. intNumberOfsubTestQuestions(i) = DLookup("numofques", "Table2", "[subcode] = '" & subcode(i) & "'" And "[tstid]= '" & Combo13 & "'")
numofques is number field in table2,tstid is the combobox.
i am getting type mismatch error
please help me
Apr 4 '07 #5
Rabbit
12,516 Expert Mod 8TB
thank u that is working.
But
Expand|Select|Wrap|Line Numbers
  1. intNumberOfsubTestQuestions(i) = DLookup("numofques", "Table2", "[subcode] = '" & subcode(i) & "'" And "[tstid]= '" & Combo13 & "'")
numofques is number field in table2,tstid is the combobox.
i am getting type mismatch error
please help me
The And logical operator is outside the string when it should be a part of it:
Expand|Select|Wrap|Line Numbers
  1. intNumberOfsubTestQuestions(i) = DLookup("numofques", "Table2", "[subcode] = '" & subcode(i) & "' And [tstid]= '" & Combo13 & "'")
Apr 4 '07 #6

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

Similar topics

7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
1
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
1
by: Megan | last post by:
Hi Everybody- I've been reading some of the posts about DCOUNT, and I haven't yet found an answer; so, I'm posting this question. I have a report that I'm trying to use DCOUNT on to compute...
4
by: Will | last post by:
Hi, I had a DCount within a module on records in a table where CustSuffix = 0. I now need to DCount where CustSuffix = 0 and the type of cost Suffix (Suffix in table) = G. I can't get both...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
2
by: Paul T. RONG | last post by:
Hi, I have a problem with DCount, the following code doesn't work: DCount("", "qryOrder", "( = Me! AND = 'drink')" > 0 Please help. Thank you.
5
by: Bruce Lawrence | last post by:
I'm running Access 97 and my modules are looping if someone puts an invalid value in. The setup: 3 macros - get_clock_num, verify_clocknum, append_to_history 3 functions. each in their own...
3
by: BerkshireGuy | last post by:
I am having difficulty with using the Dcount function. I am trying to return the number of records from qryIndividualFeedbackDetail where the TimelyManner field is set to 4. So, in the new...
1
iBasho
by: iBasho | last post by:
Hi I am using the DCount function to check and alert users for existing IDs in my database after a new record is entered. ..Private Sub CARDID_AfterUpdate() If DCount("*", "", " = '" & Me. &...
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?
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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,...
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.