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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

module to verify table is not null

Status
Not open for further replies.
Aug 30, 2001
58
US
Afternoon,

I need to create a module that will stop a series of macros with an error if a specific table is empty. I am not sure how to go about setting this up.
 
here is what I have so far

Option Compare Database
Dim SQL As String
Dim Data As String
Sub query()
SQL = "Select FIRST(OtherFee) From OtherFees"
Data = DoCmd.RunSQL SQL
End Sub
Function VerifyIT()
query
If DataGrid1 Is Null Then
DoCmd.RunMacro "stop"
End If

End Function
 
If OtherFees is the table, you could do the following

[tt]if dcount("*", "OtherFees")>0 then
' do all your code
else
msgbox "table empty"
end if[/tt]

Roy-Vidar
 
that works like a charm. now I need to have it run a macro if the table doesn't exsist at all.
 
That worked. I used an On Error statement. Heres the problem now. I have this function run in a macro like so

RunCode Function just created
RunMacro Which opens a macro that runs a series openqueries

And some more stuff...

It validates the table and then quits everything... here is the code if that'll help

Code:
Function VerifyIT()



On Error GoTo NoTable
If DCount("*", "OtherFees") > 0 Then
    MsgBox "Tables Gots Stuff In It"
  
    GoTo Exit_VerifyIt
Else
    DoCmd.RunMacro "Stop"
End If

Exit_VerifyIt:
    Exit Function

NoTable:
    MsgBox "Hump"
    Resume Exit_VerifyIt

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top