Results 1 to 4 of 4
  1. #1
    RichardAnderson is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    74

    Confusing runtime error 424 Object needed

    I have a form with the following code on the click event of a button.



    Code:
    Private Sub Command3_Click()
    
    Dim Msg, Style, Title, Response, MyString
    
    
    Msg = "You have entered a quantity made without marking the build complete." & Chr(13) & _
        "Are you sure this is what you want to do?"
    Style = vbYesNo + vbWarning
    Title = "Warning"
    
    
    If Me.Completed = True Then
        If Me.QuantityMade > 0 Then
            If Me.CompletedDate Is Not Null Then
                DoCmd.Save
                DoCmd.Close
            Else
                MsgBox "When you mark a build Complete." & Chr(13) & _
                "Make sure Quantity Made and Completed Date are entered.", vbOKOnly + vbCritical, "Error"
            End If
        Else
            MsgBox "When you mark a build Complete." & Chr(13) & _
                "Make sure Quantity Made and Completed Date are entered.", vbOKOnly + vbCritical, "Error"
        End If
    ElseIf Me.QuantityMade > 0 Then
            If Me.Completed = True Then
                DoCmd.Save
                DoCmd.Close
            Else
                Response = MsgBox(Msg, Style, Title)
                If Response = vbYes Then
                    DoCmd.Save
                    DoCmd.Close
                Else
                End If
            End If
    Else
        DoCmd.Save
        DoCmd.Close
    End If
                
    End Sub
    When I enter a number greater than 0 in the quantity made but leave the completed checkbox unchecked I get the correct msgbox.
    When I check the completed checkbox and leave the quantity made at 0 I also get the correct msgbox.

    However, If I check the completed checkbox and have a quantity made of greater than 0, I get the runtime error on the line....

    Code:
    If Me.CompletedDate Is Not Null Then
    This is very confusing to me because the object CompletedDate is there in the form.

    I have attached the db just incase...

    Open frmProduction_Schedule
    Then dbl click on the record 8
    midway down you will see the area where you mark the build complete, enter an amount made, and put in the CompletedDate.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Instead of

    If Me.CompletedDate Is Not Null Then

    try

    if not isnull(Me.CompletedDate) then

  3. #3
    RichardAnderson is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    74
    THANK YOU!!!

    This worked...

    Was the way I had it wrong? Or just just a buggy way of saying the same thing?

    Anyway, thanks a lot.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    IsNull() is a VBA function. I use it in If Then statements within VBA.

    You won't be able to check if me.Control = Null because null is not a value. A field will never = null. That is why the function is employed.

    As for Is Not Null, this is native to SQL I believe. So you should be able to type this into a query statement.

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

Similar Threads

  1. Runtime Error 424 Object Required
    By Maltheo2005 in forum Programming
    Replies: 9
    Last Post: 06-13-2013, 04:52 PM
  2. Replies: 13
    Last Post: 06-12-2012, 09:52 PM
  3. Runtime Error '3027': Database or object is read only
    By 4x4Masters in forum Programming
    Replies: 4
    Last Post: 06-08-2010, 08:02 PM
  4. Replies: 3
    Last Post: 04-15-2010, 09:43 AM
  5. Replies: 5
    Last Post: 08-05-2009, 04:07 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