Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for empty table 2

Status
Not open for further replies.

dontay

Programmer
Jan 22, 2003
49
US
Hi All,
What is a good way to check a table to see if it's empty, then return a value that I can use to exit a procedure?

Any help would help me keep my job, and impress the powers that be, or not.

Don
 
How are ya dontay . . . .

Have a look at the [purple]DCount Function.[/purple]

Calvin.gif
See Ya! . . . . . .
 
A starting point :
strTable = "myTable"
MsgBox strTable & " has " & CurrentDB.TableDefs(strTable).RecordCount & " record(s)"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks all,
Dcount worked perfit:

Dim IntCountRec As Integer
IntCountRec = DCount("[FieldName]", "tblName")
If IntCountRec < 1 Then
Exit Sub
Else
Run procedure
End If

You don't know how much this site has lifted me up.

Thank you all!!!!!!
 
Great dontay . . . . .

Shortening your code, you would have:
Code:
[blue]   If  DCount("[FieldName]", "tblName") Then
       [green]'Run procedure[/green]
   EndIf[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top