Results 1 to 6 of 6
  1. #1
    Newby is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    60

    Object required error when i am using an IF statement

    I have tried f_Update.cbxMonth.Value ; f_Update!cbxMonth.Value and me!!cbxMonth.Value for both month and year, but it doesn't like me.



    The value entered is needed to run a query. Any help would be appreciated.

    thanks in advance

    John



    Private Sub Command0_Click()

    'On Error GoTo Err_Command0_Click

    Dim stDocName As String
    'DoCmd.SetWarnings False

    If f_Update.cbxMonth.Value Is Null Or f_Update.cbxYear.Value Is Null Then
    MsgBox "Need to Select both Month and Year to posted"
    Exit Sub
    End If
    stDocName = "qa Aging ANZ GP"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    stDocName = "qa Aging West GP"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    DoCmd.SetWarnings True

    Exit_Command0_Click:
    Exit Sub

    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If that's a form reference, it doesn't look correct:

    Forms Refer to Form and Subform properties and controls
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If f_Update.cbxMonth.Value Is Null Or f_Update.cbxYear.Value Is Null Then

    This is the type of syntax used for SQL.

    In VBA, the correct syntax for testing of a control in null is:

    Code:
     If IsNull(f_Update.cbxMonth) Or IsNull(f_Update.cbxYear) Then
    What is "f_Update" ?

  4. #4
    Newby is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    60
    f_Update is a form. Does that change your answer?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If it is a form and not a subform AND the control is on that form, I would try

    Code:
    If IsNull(Me.cbxMonth) Or IsNull(Me.cbxYear) Then

  6. #6
    Newby is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    60
    Great. Thanks a bunch?

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

Similar Threads

  1. Object Required Error
    By sgp667 in forum Programming
    Replies: 1
    Last Post: 11-06-2012, 03:15 AM
  2. Error: Object Required
    By compooper in forum Programming
    Replies: 6
    Last Post: 06-22-2011, 07:52 AM
  3. Object Required Error.
    By Robeen in forum Forms
    Replies: 1
    Last Post: 03-28-2011, 10:30 AM
  4. Replies: 2
    Last Post: 08-05-2010, 08:16 AM
  5. Run-time error '424': Object required
    By cowboy in forum Programming
    Replies: 18
    Last Post: 07-07-2010, 03:32 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