Solved Count() function in an unbound start form (1 Viewer)

lodmark

Member
Local time
Today, 02:18
Joined
Jul 24, 2020
Messages
232
Now that my database is almost finished, thanks to you in the forum.
I have now started to add vinyl records and radio programs.
I thought I would spice it up with some nice features.
I have created a start form and hidden the access program itself.
I thought it would have been nice to have the number of records, artists and songs presented on the start form.
The Count () function should be usable, but it does not work on the startup form.
If I test the function on a bound form, I can see the number of rows in the table or question directly but not in the unbound form.
Since data is retrieved from different tables, I can not link the start form to a source.
I have tested both individual tables and questions but have not succeeded.
I wonder what to do?

Leif
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:18
Joined
Oct 29, 2018
Messages
21,454
Hi. If you're trying to use an unbound form, then maybe you can use the DCount() function instead of just Count().
 

lodmark

Member
Local time
Today, 02:18
Joined
Jul 24, 2020
Messages
232
Hi. If you're trying to use an unbound form, then maybe you can use the DCount() function instead of just Count().
I've tried that but I didn't get it right. Looked in this forum for the code but it didn't work.
Leif
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:18
Joined
Oct 29, 2018
Messages
21,454
I've tried that but I didn't get it right. Looked in this forum for the code but it didn't work.
Leif
Can you show us exactly what you tried and elaborate on what you mean by "it didn't work?" Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:18
Joined
Oct 29, 2018
Messages
21,454
I will post the database later tonight.
Okay, sounds good. In the meantime, on a bound form, this might work:
Code:
=Count(*)

But on an unbound form, you could try this:
Code:
=DCount("*","TableName")
 

lodmark

Member
Local time
Today, 02:18
Joined
Jul 24, 2020
Messages
232
Okay, sounds good. In the meantime, on a bound form, this might work:
Code:
=Count(*)

But on an unbound form, you could try this:
Code:
=DCount("*","TableName")

Thanks @theDBguy DCount() worked. The funny thing is that when I tried it I've used the "the expression tool" and then the table name was surrounded by square brackets and then it did not work.
When I wrote in your code iy worked.
Leif
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:18
Joined
Oct 29, 2018
Messages
21,454
Thanks @theDBguy DCount() worked. The funny thing is that when I tried it I've used the "the expression tool" and then the table name was surrounded by square brackets and then it did not work.
When I wrote in your code iy worked.
Leif
Hi. Glad to hear you got it to work. Good luck with your project.
 

bob fitz

AWF VIP
Local time
Today, 01:18
Joined
May 23, 2011
Messages
4,719
Thanks @theDBguy DCount() worked. The funny thing is that when I tried it I've used the "the expression tool" and then the table name was surrounded by square brackets and then it did not work.
When I wrote in your code iy worked.
Leif
I believe the speech marks (") are always required but the square brackets [ ] are only required if there are one or more spaces in the name
 

lodmark

Member
Local time
Today, 02:18
Joined
Jul 24, 2020
Messages
232
@theDBguy I Had to show the result!
Skärmklipp.PNG
 

Users who are viewing this thread

Top Bottom