Results 1 to 6 of 6
  1. #1
    LOUM is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    9

    Form debug error

    Hello everyone:

    When I run the debug i get a compile error with the below code.



    Private Sub Combo118_BeforeUpdate(Cancel As Integer)
    If IsNull(Me.Combo118) Then
    MsgBox "The blank field is required....", vbOKOnly
    Me.Combo118.SetFocus
    Cancel = True
    Exit Sub
    End If
    End Sub

    It states it cannot find Combo118.

    How can I find where this was used on a form and which form?

    Thank you.
    Lou

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    All you need is the "Cancel = True" to hold the focus in the control. No SetFocus code needed.

  3. #3
    LOUM is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    9
    Thank you for the quick reply.

    When I remove the Setfocus I still receive the compile error indicating "Method or datamember not found".

    Lou

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by LOUM View Post
    ...When I run the debug i get a compile error with the below code.

    Private Sub Combo118_BeforeUpdate(Cancel As Integer)
    If IsNull(Me.Combo118) Then
    MsgBox "The blank field is required....", vbOKOnly
    Me.Combo118.SetFocus
    Cancel = True
    Exit Sub
    End If
    End Sub

    It states it cannot find Combo118.

    How can I find where this was used on a form and which form?
    If you're getting a Compile Error Access should be taking you to the code in the Code Module for the Form where it resides! Just look up at the Form Header for the name!

    If Combo118 does actually exist on the Form, Access may be balking at the line

    Me.Combo118.SetFocus

    Located in the Combo118_BeforeUpdate event, the line is not needed; the line

    Cancel = True

    in the BeforeUdate event, would insure that the Focus will remain in the Control.

    But the entire code is located in the wrong event! If the user simply doesn't make a selection from Combo118, the event will never fire and the Validation will not be run! Validation code to insure that a Control is not Null simply has to be in the Form_BeforeUpdate event!

    It is quite possible that during development Combo118 was either deleted or re-named.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the intellisense. On this line: If IsNull(Me.Combo118) Then
    ...delete the Combo118 and the dot before it. Then put in the dot again and a list should drop down of all of the legal possibilities to select. Reselect Combo118 if it is there and then recompile again.

  6. #6
    LOUM is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    9
    Linq.

    Thank you, I am leaning toward the combo was deleted. How can I delete the code correctly that is referencing it?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. TempVars monitoring for debug
    By chris.williams in forum Programming
    Replies: 2
    Last Post: 11-18-2011, 03:27 PM
  2. disable debug error
    By alex_raju in forum Access
    Replies: 1
    Last Post: 08-13-2011, 12:19 PM
  3. Debug
    By gio25 in forum Programming
    Replies: 1
    Last Post: 02-08-2011, 08:30 AM
  4. Access Form will not debug
    By Gene in forum Programming
    Replies: 4
    Last Post: 06-27-2009, 03:46 PM
  5. Is There a Way to Debug or Step Through VB code?
    By jeffbase34 in forum Programming
    Replies: 1
    Last Post: 05-28-2009, 08:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums