DCount

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I need to recreate a form in Excel from Access. In the Access form I use

Code:
 If DCount("*", "tblLicences") =0 Then

What the equivalent be in Excel?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
There isn't a direct equivalent. As long as you have a column in your table that is always populated for a given row, you could use COUNTA(Tablename[ColumnName])
 
Upvote 0
I have tried

Code:
intFindLastRow = WorksheetFunction.CountA(tblLicences, [FIELD23])

But I always get a return value of 2 even though there are more than 2 rows with 23 columns all populated. It's the number of rows that I am after.
 
Upvote 0
You can't refer to ranges like that in VBA, you should use:

Code:
intFindLastRow = WorksheetFunction.CountA(Range("tblLicences[FIELD3]"))

or:

Code:
intFindLastRow = WorksheetFunction.CountA(Sheets("sheet name").Listobjects("tblLicences").Listcolumns("FIELD3").Databodyrange)
 
Upvote 0
Solution
You can't refer to ranges like that in VBA, you should use:

Code:
intFindLastRow = WorksheetFunction.CountA(Range("tblLicences[FIELD3]"))

or:

Code:
intFindLastRow = WorksheetFunction.CountA(Sheets("sheet name").Listobjects("tblLicences").Listcolumns("FIELD3").Databodyrange)

Both worked. Many thanks.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top