Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 23rd, 2012, 05:15 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old November 26th, 2012, 11:55 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:54 PM.


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