I want to check if my FE is connected to BE
So If it is conneted make txtbox green and caption it is "online" ealse txtbox read caption "offline"
Sometimes I distribute FE file, but it is not linked to the tables
Public Function IsConnectedToBE() As Boolean
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = Currentdb
On Error Resume Next
Se rs = db.TableDefs("LinkedTable").OpenRecordset
IsConnectedToBE = (Err = 0)
Set rs = Nothing
Set db = Nothing
End Function
Public Function IsConnectedToBE() As Boolean
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = Currentdb
On Error Resume Next
Se rs = db.TableDefs("LinkedTable").OpenRecordset
IsConnectedToBE = (Err = 0)
Set rs = Nothing
Set db = Nothing
End Function
Thanks but I have small problems
I open new form
I insert textbox
I put the function in Record Source, but the results always 0 (false) whether there are local tables or related tables, I got same result
recordsource should be sql or the name of a table or query
also presume you changed 'LinkedTable' in the function to the name of one of your linked tables
suggest call it from your form open event
Code:
if IsConnectedToBE then
txtbox.backcolor=vbgreen
txtbox="online"
recordsource="name of table or query"
else
txtbox.backcolor=vbred
txtbox="offline"
recordsource=""
end if