why this calculation VBA is not workable?

  • Thread starter Thread starter Martin \(Martin Lee\)
  • Start date Start date
M

Martin \(Martin Lee\)

Why this calculation VBA is not workable?

[Text1043] = DCount("[status]", "DLRINQIRY", "[status] = 'OK' and
[DLRNAME]=combo1125")


How to correct it ?

Thank you!


Martin
 
Martin (Martin Lee) said:
Why this calculation VBA is not workable?

[Text1043] = DCount("[status]", "DLRINQIRY", "[status] = 'OK' and
[DLRNAME]=combo1125")

How to correct it ?

Because you have not explained what you have nor what you are trying to
accomplish, we can only guess. My guess would be that you are trying to use
a text value selected by the user in a ComboBox named combo1125 on a Form to
compare against the Field DLRNAME and that you want to find and store the
count of records meeting the criteria in a TextBox named Text 1043 and, if
so, for clarity, I'll use some extra statements

Dim strCriteria as String
strCriteria = "[status] = ""OK"" AND [DLRNAME] = """ & Me.combo1125 & """"
Me.Text1043 = DCount("[status]", "DLRINQIRY", strCriteria)

But, as I said, that's only a guess.

And, I'll add, it's the LAST TIME I am going to waste my time and energy
trying to GUESS what you are trying to accomplish when you post code or
question with no explanation of what you have and what you are trying to
accomplish and ask why it isn't working. For good suggestions on effective
use of newsgroups, please read http://www.mvps.org/access/netiquette.htm.

Larry Linson
Microsoft Access MVP
 
Concatenate the value of the combo into the 3rd string:
Me.Text1043 = DCount("*", "DLRINQIRY", _
"([status] = 'OK') and ([DLRNAME] = " & Me.combo1125 & ")")

If DLRName is a Text field (not an Number field), you need extra quotes:
"([status] = 'OK') and ([DLRNAME] = """ & Me.combo1125 & """)")

For an explanation, see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html
and:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html
 
This should work:

[Text1043] = DCount("[status]", "[DLRINQIRY]", "[status] = 'OK' and
[DLRNAME]='combo1125'")
 

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

Back
Top