Dcount question

  • Thread starter Thread starter Iram
  • Start date Start date
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
 
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.
 
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.
 
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
 
=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
 
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] & "*' ")
 
Back
Top