Wrox Programmer Forums
|
BOOK: Access 2010 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2010 Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison; ISBN: 978-0-470-59166-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2010 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2012, 05:15 PM
Registered User
 
Join Date: Nov 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 256 line 16 Invalid use of Null

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
 
Old November 26th, 2012, 11:55 AM
Registered User
 
Join Date: Nov 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Solution found!

I found out when i was running into the error and fixed the problem. I had to add the option button to the option group in order for the form to correctly reference the buttons. Thanks to everyone who helped.

p.s.

I had to selected the option group and then click the add option button to make it add the button correctly.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch10 this keyword page 256 arun_babu_a BOOK: Beginning Visual C# 2010 8 October 27th, 2011 04:05 AM
Invalid Use of Null arholly Access VBA 5 February 5th, 2007 08:18 AM
Invalid use of Null: 'cstr' shoakat Classic ASP Databases 1 November 2nd, 2004 07:51 PM
Calculator Using Postback - page 256 ukbrit Dreamweaver (all versions) 1 November 2nd, 2004 05:04 PM
Invalid use of Null LT2003 All Other Wrox Books 3 December 1st, 2003 04:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.