Solved Dcount yeild 0

sbaud2003

Member
Local time
Tomorrow, 01:40
Joined
Apr 5, 2020
Messages
184
hi
i am using the Codes below bot result is Zero
Actually I want the user to get the number of Books available in the Library with the same title when select a particular book from the ComboBox "COMT"


Val = DCount("[Title]", "[BOOK]", "[Title] = " & "'" & Forms!FrmBook!COMT & "'")
 
Val is a function so shouldn't be used as a variable name.

SomeVariable = DCount("*", "[BOOK]", "[Title] = """ & Forms!FrmBook!COMT & """")
 
Hi. For starters, try using something else than Val for the name of your variable.

Oops, too slow...
 
what is the Rowsource of your combo? how many Columns are there?
if only 1 column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT & "'")

if 2 column and first column is the bound column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT.Column(1) & "'")
 
You have some extra quotes in there...
 
what is the Rowsource of your combo? how many Columns are there?
if only 1 column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT & "'")

if 2 column and first column is the bound column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT.Column(1) & "'")
Thanks you sir,,,,,
Its working
One More Help Required
I am accessing the Title of the Book through the combo Box, name COMT through a query, but it displyas all the books of same name even they have diferent BOOK ID, I have applied Distinct clause but does not work....
Is there any way to list the name of the Books with single title even they have many in the library.
 
what is the Rowsource of your combo? how many Columns are there?
if only 1 column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT & "'")

if 2 column and first column is the bound column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT.Column(1) & "'")

Thanks you sir,,,,,
Its working
One More Help Required
I am accessing the Title of the Book through the combo Box, name COMT through a query, but it displyas all the books of same name even they have diferent BOOK ID, I have applied Distinct clause but does not work....
Is there any way to list the name of the Books with single title even they have many in the library.
 
what is the Rowsource of your combo? how many Columns are there?
if only 1 column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT & "'")

if 2 column and first column is the bound column:

Val = DCount("[Title]", "[BOOK]", "[Title] = '" & Forms!FrmBook!COMT.Column(1) & "'")
Thanks you sir,,,,,
Its working
One More Help Required
I am accessing the Title of the Book through the combo Box, name COMT through a query, but it displyas all the books of same name even they have diferent BOOK ID, I have applied Distinct clause but does not work....
Is there any way to list the name of the Books with single title even they have many in the library.
 
but it displyas all the books of same name even they have diferent BOOK ID, I have applied Distinct clause but does not work....

if you have more than 1 column the whole row must be distinct.
"Select distinct Bookname, ID from tblBooks" - will return both name and id's that are unique. so if name is unique and ID isn't it will return all unique name/ID combinations.

"Select distinct Bookname from tblBooks" - will work
 
if you have more than 1 column the whole row must be distinct.
"Select distinct Bookname, ID from tblBooks" - will return both name and id's that are unique. so if name is unique and ID isn't it will return all unique name/ID combinations.

"Select distinct Bookname from tblBooks" - will work
thanks
 

Users who are viewing this thread

Back
Top Bottom