Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dcount: data type mismatch 2

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
Hallo,
I have a problem with the dcount function.
There are two tables: tbl_Organization and tbl_Otype (organization and organization type). They are linked by the field Org_OtypeID. The aim now is to have a continuous form where I can display the number of organization of each type. So what I did is a form with source in the tbl_Otype table. In the form I show the type (Oty_Type) and the type ID (Oty_ID). Now it comes the dcount function: I would like it to count the records in Organization table that match with the type ID in the form... in other words:
=DCount("[Org_OTypeID]";"tbl_Organization";"Org_OTypeID='" & [Oty_ID] & "'")

It should count the typeID field in the organization table, but only if it match with the typeID (from Type table) in the form... but it says that there is a data type mismatch.
Does someone have a suggestion? thanks

NB: I put the code as a control source of a textbox and not in VBA
 
If the Org_OTypeID field is numeric, then try:

[tt]=DCount("[Org_OTypeID]";"tbl_Organization";"Org_OTypeID=" & [Oty_ID])[/tt]

Single quotes are text delimiters.

BTW - usage of semicolon as arguement separators are used in contries where comma (,) is used as decimal separator. If your country doesn't, you might try to change to commas (the wrong separator should provide "Invalid syntax" or something to that equivalent).

Roy-Vidar
 
If Org_OtypeID is defined as numeric, eplace this:
=DCount("[Org_OTypeID]";"tbl_Organization";"Org_OTypeID='" & [Oty_ID] & "'")
By this:
=DCount("[Org_OTypeID]";"tbl_Organization";"Org_OTypeID=" & [Oty_ID])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top