Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
I am getting an "Object variable or With block variable not set" error with the line highlighted in red below. 'frmservice' refers to userform "frm_tservices", and is declared publically as an object at the start of my project. It's always been a challenge for me understanding how to refer to forms in standard modules and I think this proves the obvious.
This above procedure is called (purple line) from this procedure ...
Rich (BB code):
Sub iupdate_srvcufrm(ByRef frmservice As Object)
Application.ScreenUpdating = False
srvcs_no = Application.WorksheetFunction.CountA(ws_thold.Range("AK1:AK8"))
'Stop 'try save SAVE OK
If srvcs_no = 1 Then
frmservice.Controls("btn_help").Visible = False
frmservice.Controls("cbt_s1_del").Visible = True
frmservice.Controls("cbt_s1_del").Enabled = True
frmservice.Controls("cbt_s1_end").Enabled = True
frmservice.Controls("cbt_s1_add").Enabled = True
If ojs = True Then
frmservice.Controls("frm_service1").Caption = " SERVICE 1** "
Else
frmservice.Controls("frm_service1").Caption = " SERVICE 1* "
End If
End If
.....
This above procedure is called (purple line) from this procedure ...
Rich (BB code):
Sub ichk_overlap(ByRef add_start As Double)
Dim frmservice As Object
'Set frmservice = Me 'this resulted in an invalid use of Me keyword
With ws_thold
.Visible = xlSheetVisible
.Activate
no_svcs = Application.WorksheetFunction.CountA(.Range("AJ1:AJ8"))
If no_svcs = 1 Then Exit Sub 'nothing to compare to
For samir = 1 To no_svcs
txt_h_lwr = .Cells(samir, 37)
txt_h_upr = .Cells(samir, 38)
If Right(txt_h_lwr, 1) = "A" Then l_ap = "AM"
If Right(txt_h_lwr, 1) = "P" Then l_ap = "PM"
If Right(txt_h_upr, 1) = "A" Then u_ap = "AM"
If Right(txt_h_upr, 1) = "P" Then u_ap = "PM"
tm_h_lwr = Left(txt_h_lwr, Len(txt_h_lwr) - 1)
tm_h_upr = Left(txt_h_upr, Len(txt_h_upr) - 1)
str_h_lwr = tm_h_lwr & " " & l_ap
str_h_upr = tm_h_upr & " " & u_ap
h_lwr = CDate(str_h_lwr)
h_upr = CDate(str_h_upr)
'Stop
If add_start >= h_lwr And add_start <= h_upr And .Cells(samir, 37).Font.Color = vbBlack Then
MsgBox "There is already a service scheduled for tis time period.", vbExclamation, "ERROR: Overlapping Service"
For fgrnln = 1 To 8
If .Cells(fgrnln, 37).Font.Color = vbGreen Then
.Range("AJ" & fgrnln & ":AQ" & fgrnln).Delete Shift:=xlUp
iupdate_srvcufrm frmservice
Exit For
End If
Next fgrnln
Exit Sub
End If
Next samir
End With
End Sub