dcount question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi to all. I have a silly question but I cannot figure it out.

I have a database with a table that holds all the computer repair request
information. In the table, called CRR, I have a field that says if that CRR
is alrealdy resolved or if it's still in progress. If it is resolved I have a
1 and if it is not a 2.

Now, I want my form to tell me how many of my CRRs are resolved and how many
are not. For that, I have a button in my form. I put the following code:

Private Sub cmdCRRResolved_Click()
Dim lngResolved As String

lngResolved = DCount("*", "CRR", [id_status] = 1)
MsgBox "There are " & lngResolved & " CRR resolved."

End Sub

But it brings 0 Resolved if I'm standing on a record that is "in progress"
and the totality of my CRR records (so far 61) if I'm stading in a record
that is "Resolved"

I don't know what do I have to do, but if you have any ideas, please help me
out here.

thank you in advance for your help.
 
If you copied this code, then you need to add a double quote in the criteria

Yours
lngResolved = DCount("*", "CRR", [id_status] = 1)

Should be
lngResolved = DCount("*", "CRR", "[id_status] = 1")

Also, if the id_status is text type, then try
lngResolved = DCount("*", "CRR", "[id_status] = '1'")
=====================================
One last thing, define lngResolved as a number type and not string, it
spose to hold a number

Dim lngResolved As Long
 
hi Ofer: Thank you very much!!! It worked with the doble quote. I've tried
them but not like you did...hahaha. And yes, the lngResolved as it was not
working I set it up as a string to see if that way it would work, and then I
forgot to change it back. Glad you noticed and told me to change it.

ok, you've been veeeery nice and helpful to me Ofer. I really appreciate
your help!
have a very nice day!




Ofer Cohen said:
If you copied this code, then you need to add a double quote in the criteria

Yours
lngResolved = DCount("*", "CRR", [id_status] = 1)

Should be
lngResolved = DCount("*", "CRR", "[id_status] = 1")

Also, if the id_status is text type, then try
lngResolved = DCount("*", "CRR", "[id_status] = '1'")
=====================================
One last thing, define lngResolved as a number type and not string, it
spose to hold a number

Dim lngResolved As Long


--
HTH, Good Luck
BS"D


lula said:
hi to all. I have a silly question but I cannot figure it out.

I have a database with a table that holds all the computer repair request
information. In the table, called CRR, I have a field that says if that CRR
is alrealdy resolved or if it's still in progress. If it is resolved I have a
1 and if it is not a 2.

Now, I want my form to tell me how many of my CRRs are resolved and how many
are not. For that, I have a button in my form. I put the following code:

Private Sub cmdCRRResolved_Click()
Dim lngResolved As String

lngResolved = DCount("*", "CRR", [id_status] = 1)
MsgBox "There are " & lngResolved & " CRR resolved."

End Sub

But it brings 0 Resolved if I'm standing on a record that is "in progress"
and the totality of my CRR records (so far 61) if I'm stading in a record
that is "Resolved"

I don't know what do I have to do, but if you have any ideas, please help me
out here.

thank you in advance for your help.
 
Your welcome, glad I could help.
Have a great day

--
HTH, Good Luck
BS"D


lula said:
hi Ofer: Thank you very much!!! It worked with the doble quote. I've tried
them but not like you did...hahaha. And yes, the lngResolved as it was not
working I set it up as a string to see if that way it would work, and then I
forgot to change it back. Glad you noticed and told me to change it.

ok, you've been veeeery nice and helpful to me Ofer. I really appreciate
your help!
have a very nice day!




Ofer Cohen said:
If you copied this code, then you need to add a double quote in the criteria

Yours
lngResolved = DCount("*", "CRR", [id_status] = 1)

Should be
lngResolved = DCount("*", "CRR", "[id_status] = 1")

Also, if the id_status is text type, then try
lngResolved = DCount("*", "CRR", "[id_status] = '1'")
=====================================
One last thing, define lngResolved as a number type and not string, it
spose to hold a number

Dim lngResolved As Long


--
HTH, Good Luck
BS"D


lula said:
hi to all. I have a silly question but I cannot figure it out.

I have a database with a table that holds all the computer repair request
information. In the table, called CRR, I have a field that says if that CRR
is alrealdy resolved or if it's still in progress. If it is resolved I have a
1 and if it is not a 2.

Now, I want my form to tell me how many of my CRRs are resolved and how many
are not. For that, I have a button in my form. I put the following code:

Private Sub cmdCRRResolved_Click()
Dim lngResolved As String

lngResolved = DCount("*", "CRR", [id_status] = 1)
MsgBox "There are " & lngResolved & " CRR resolved."

End Sub

But it brings 0 Resolved if I'm standing on a record that is "in progress"
and the totality of my CRR records (so far 61) if I'm stading in a record
that is "Resolved"

I don't know what do I have to do, but if you have any ideas, please help me
out here.

thank you in advance for your help.
 

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

Similar Threads

if clause in access 2000 12
Shape top position in Excel 2007 4
report 8
refresh on a form 2
Access Dcount (multiple criteria) 3
Access Dcount function in access 0
Search and lookup functions 1
Importing Word into Access 2000. Please Help.. 14

Back
Top