Garren.Shannon
Member
- Local time
- Today, 08:38
- Joined
- Sep 22, 2022
- Messages
- 113
Hey all,
I am testing to see if my app is connected to the SQL server or not. If it is not, I want to hide the upload button on frm_TripsEditOrUpload. The command Set UpLoadButtonVisible = Forms!FrmTripsEditOrUpload!.UploadBtn fails with a debug statement saying it can't find the form. In the image, you can see the list of forms and such.
I have read through several posts on how to reference an object on a form and I believe this should be working... but it blows.
The code is coming from the Form_Load() for the Frm_StartUp form which auto-loads on start.
I am testing to see if my app is connected to the SQL server or not. If it is not, I want to hide the upload button on frm_TripsEditOrUpload. The command Set UpLoadButtonVisible = Forms!FrmTripsEditOrUpload!.UploadBtn fails with a debug statement saying it can't find the form. In the image, you can see the list of forms and such.
I have read through several posts on how to reference an object on a form and I believe this should be working... but it blows.
The code is coming from the Form_Load() for the Frm_StartUp form which auto-loads on start.
Code:
Private Sub Form_Load()
Dim UpLoadButtonVisible As TextBox
OnNet = False
On Error GoTo Form_Open_Error
opt = MesgBox("Checking your Network connection... Please wait", 5)
If DCount("*", "dbo_Vehicles") > 0 Then
DoCmd.SetWarnings (False)
DoCmd.OpenQuery ("ResetVehiclesQuery")
DoCmd.OpenQuery ("AppendFromDBO_Vehicles")
DoCmd.OpenQuery ("ResetDriversQuery")
DoCmd.OpenQuery ("AppendFromDBO_Drivers")
DoCmd.OpenQuery ("ResetSchoolYrDatesQuery")
DoCmd.OpenQuery ("AppendFromDBO_SchoolYrDates")
'Turn the warnings back on
DoCmd.SetWarnings (True)
OnNet = True
End If
' Else
' MsgBox ("I can't reach the master database at this time but you can still add trips!")
' End If
Form_Open_Error:
If OnNet = False Then
MsgBox ("Your not on the network but you can still add your trips")
Set UpLoadButtonVisible = Forms!FrmTripsEditOrUpload!.UploadBtn
UpLoadButtonVisible = False
Else
MsgBox ("Connected!")
End If
DoCmd.Close acForm, "StartUp", acSaveNo
DoCmd.OpenForm "Frm_MainMenu", acNormal
Forms("Frm_MainMenu").Move 0, 0
End Sub