Hey all,
I am learning VBA for the company I work for an I am running into issues with the practice code. I have
copied the code exactly as it is shown in the book to the best of my copying abilities. I continue to get a runtime error 94 which is an invalid use of Null. I tried using Notepad++ to compare the example code that I downloaded off the website and they are identical. Here and a snippet of my code and the example give with my code's incorrect code supposedly.
My code...
Code:
Option Compare Database
Option Explicit
'Declare the object variable using WithEvents
Private WithEvents Dlg As Form_DlgMyDialog
Private Sub cmdClose_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdSelect_Click()
'Instantiate the dialog
Set Dlg = New Form_DlgMyDialog
'Enable the appropriate combo
Dlg.WhichOne = Me.optMyOptionGroup
'If we had declared dialog properties, we
'could pass their values here:
'Dlg.Property1 = 123
'Dlg.Property2 = "some value"
'etc...
'Show the dialog
Dlg.Visible = True
End Sub
Private Sub Dlg_Finished(varReturn As Variant)
Me.txtMyTextBox.Enabled = (Not IsNull(varReturn))
If Not IsNull(varReturn) Then
Me.txtMyTextBox = varReturn
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Clean Up
Set Dlg = Nothing
End Sub
Example code...
Code:
Option Compare Database
Option Explicit
'Declare the object variable using WithEvents
Private WithEvents dlg As Form_DlgMyDialog
Private Sub cmdClose_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdSelect_Click()
'Instantiate the dialog
Set dlg = New Form_DlgMyDialog
'Enable the appropriate combo
dlg.WhichOne = Me.optMyOptionGroup
'If we had declared dialog properties, we
'could pass their values here:
'dlg.Property1 = 123
'dlg.Property2 = "some value"
'etcâ¦
'Show the dialog
dlg.Visible = True
End Sub
Private Sub dlg_Finished(varReturn As Variant)
Me.txtMyTextbox.Enabled = (Not IsNull(varReturn))
If Not IsNull(varReturn) Then
Me.txtMyTextbox = varReturn
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Clean up
Set dlg = Nothing
End Sub