Why does this give me a runtime error 424 ... object required
VB Code:
Public Sub Opt(chkbox As CheckBox) If chkbox.Value = False Then chkbox.Caption = "Add" ElseIf chkbox.Value = True Then chkbox.Caption = "Option" End If End Sub
Seahag
Printable View
Why does this give me a runtime error 424 ... object required
VB Code:
Public Sub Opt(chkbox As CheckBox) If chkbox.Value = False Then chkbox.Caption = "Add" ElseIf chkbox.Value = True Then chkbox.Caption = "Option" End If End Sub
Seahag
This works for me ...
VB Code:
Option Explicit Public Sub Opt(chkbox As CheckBox) If Not chkbox.Value = 0 Then chkbox.Caption = "Box was not ticked" Else chkbox.Caption = "Box was ticked" End If End Sub Private Sub CheckBox1_Click() Opt CheckBox1 End Sub
Are you passing it a true object box?
Also, at the beginning of the code where that routine is (form/module/etc) put this line if its not already there:
Option Explicit
This will help debug your code.