Dcount question

I

Iram

Hello.

I am trying to create an expression but it's not working... Its for a field
on a form...


=DCont("[ReportCode]","tbl_MasterContinued","[ReportCode] = 'A' and
[Anotado] = Like *& Forms![frm_Reports]![AnotadoFormField]&*")

I am trying to count all of the "ReportCode"s in the table
tbl_MasterContinued where the "ReportCode" equals "A" and where "Anotado" is
like a field on a form called "AnotadoFormField" in form frm_Reports.


Note: Anotado is the name of another field in tbl_MasterContinued.


Can you help me fix this?


Thanks.
Iram
 
D

Doctor

DCount is mispelled. But maybe try this too.

=DCount("[ReportCode]","tbl_MasterContinued","[ReportCode] = 'A' AND
[Anotado] = Like '*" & Forms![frm_Reports]![AnotadoFormField] &'*")

The last field needs extra quotes around it if it is a text field.
 
F

fredg

Hello.

I am trying to create an expression but it's not working... Its for a field
on a form...

This is used on an UNBOUND text control on the form named
"frm_Reports"? You can use just the name of the control
[AnotadoFormField] without using the full qualifier
forms!frm_Report![AnotadoFormField]
=DCont("[ReportCode]","tbl_MasterContinued","[ReportCode] = 'A' and
[Anotado] = Like *& Forms![frm_Reports]![AnotadoFormField]&*")

I am trying to count all of the "ReportCode"s in the table
tbl_MasterContinued where the "ReportCode" equals "A" and where "Anotado" is
like a field on a form called "AnotadoFormField" in form frm_Reports.

Note: Anotado is the name of another field in tbl_MasterContinued.

Can you help me fix this?

Thanks.
Iram

Please always copy and paste your code so we can see exactly what you
have written.

1) You wrote = DCont( ...etc.)
The word is DCount, so that might be part of your problem or it might
be just a miss-spelling here in this post.

2) When using wildcards, nothing is "= Like". Just use Like with
wildcards.

3) A text value must be enclosed in quotes, i.e. Like "*Sm*".

4) Assuming the form control is just a partial value and you need the
wildcards, try it this way:

=DCount("*","tbl_MasterContinued","[ReportCode] = 'A' and
[Anotado] Like ""*" & [AnotadoFormField] & "*""")

The above assumes both [ReportCode] and [Anotado] are Text datatype
fields.
 
I

Iram

Hello Doctor and fredg

I have tried both of your expressions see below for the real field names
however they are so close they are not working yet. Note "Anotado En" is on
the form and "AnotadoEn" is in the table.


Doctor
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' AND [AnotadoEn] =
Like '*" & Forms![frm_Reports]![Anotado En] &'*")

Fredg
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' And [AnotadoEn]
Like ""*" & [Anotado En] & "*""")


What am I doing wrong?

Iram/mcp
 
R

RonaldoOneNil

=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' And [AnotadoEn]
Like *" & Forms![frm_Reports]![Anotado En] & "*")

Iram said:
Hello Doctor and fredg

I have tried both of your expressions see below for the real field names
however they are so close they are not working yet. Note "Anotado En" is on
the form and "AnotadoEn" is in the table.


Doctor
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' AND [AnotadoEn] =
Like '*" & Forms![frm_Reports]![Anotado En] &'*")

Fredg
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' And [AnotadoEn]
Like ""*" & [Anotado En] & "*""")


What am I doing wrong?

Iram/mcp






Iram said:
Hello.

I am trying to create an expression but it's not working... Its for a field
on a form...


=DCont("[ReportCode]","tbl_MasterContinued","[ReportCode] = 'A' and
[Anotado] = Like *& Forms![frm_Reports]![AnotadoFormField]&*")

I am trying to count all of the "ReportCode"s in the table
tbl_MasterContinued where the "ReportCode" equals "A" and where "Anotado" is
like a field on a form called "AnotadoFormField" in form frm_Reports.


Note: Anotado is the name of another field in tbl_MasterContinued.


Can you help me fix this?


Thanks.
Iram
 
A

AccessVandal via AccessMonster.com

Try this

=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A'" & " AND [AnotadoEn]
= Like '*" & Forms![frm_Reports]![Anotado En] &'*")

The diffrence is [ReporteClaveEl] = 'A'" & " AND [AnotadoEn] = Like '*"
Hello Doctor and fredg

I have tried both of your expressions see below for the real field names
however they are so close they are not working yet. Note "Anotado En" is on
the form and "AnotadoEn" is in the table.

Doctor
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' AND [AnotadoEn] =
Like '*" & Forms![frm_Reports]![Anotado En] &'*")

Fredg
=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A' And [AnotadoEn]
Like ""*" & [Anotado En] & "*""")

What am I doing wrong?

Iram/mcp
[quoted text clipped - 14 lines]
Thanks.
Iram
 
A

AccessVandal via AccessMonster.com

Opps typos..

AccessVandal wrote:
Try this

=DCount("*","tbl_MasterContinued","[ReporteClaveEl] = 'A'" & " AND [AnotadoEn]
Like '*" & Forms![frm_Reports]![Anotado En] &'*")

The diffrence is [ReporteClaveEl] = 'A'" & " AND [AnotadoEn] Like '*"
 
A

AccessVandal via AccessMonster.com

Hmm, I don't recall that you can use a query in the Dcount.

You might want to create one and try it out.

Create a query base on the two tables and use this query as the domain. Like

DCount("*", "QueryName", "[ReporteClaveEl] = 'A'" & " AND [AnotadoEn] Like
'*" & Forms![frm_Reports]![Anotado En] &'*")

If it's gets more complicated or difficult, you can create a function to
return the results by creating a recordset by filtering from your criteria
above.
I made a mistake.
"AnotadoEn" is in another table called "tbl_Master". Both tables
"tbl_Master" and "tbl_MasterContinued" are both linked by a one to one
relationship by fields called "Codigo" in both tables.

Is it possible to still get this formula to work?

Your help is greatly appreciated.

Iram/mcp
Opps typos..
[quoted text clipped - 4 lines]
The diffrence is [ReporteClaveEl] = 'A'" & " AND [AnotadoEn] Like '*"
 
C

Chegu Tom

Many of the suggestions seem to be missing a quotation mark near the end

]![AnotadoFormField]&*")

Should be for a numeric field

]![AnotadoFormField] & "*")

For a text field
]![AnotadoFormField] & "*' ")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top