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

Pass a value from a module to a macro 1

Status
Not open for further replies.

edsearl

Programmer
Joined
May 8, 2002
Messages
24
Location
US
The following coding checks an ODBC table to see if the connection is OK.
How do I get it to tell the macro that runs it to stop if the connection is bad?

Public Function IsTableThere()
On Error GoTo Err_IsTableThere
DoCmd.OpenTable "PS$O_Table"
DoCmd.Close acTable, "PS$O_Table", acSaveNo
Exit_IsTableThere:
Exit Function
Err_IsTableThere:
Err.Clear
End Function

Thank You
 
You will need to return something from the function:

Code:
Public Function IsTableThere()
dim db as dao.database
dim td as dao.tabledef
set db = currentdb
on error resume next
td = db.tabledefs("PS$O_Table")
if err.number<>0 then
  ' not found 
  IsTableThere=False
  err.clear
else
  IsTableThere=True
end if

You can then check in your macro whether the return is false or true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top