VBA RTE 424; Object Required

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dbrother
    New Member
    • Nov 2007
    • 19

    VBA RTE 424; Object Required

    Hello,
    I'm receiving a "424 Run time error: Object required" in the simple program that I've created in Access 2K3 SP2. The program is in a manufacturing environment. Here's an overview of the process: an operator will scan a 2D barcode, that input triggers an engraver to engrave the input onto metal. Then a verification camera takes a picture and verifies the mark to the original data.

    I get the error code on the first line when trying to communicate with port COM1. The error line is in bold and if I comment our that line, it just gives the error on the next line and so on....
    It seems as though VB thinks that "MSComm0" is a variable.
    And as usual, the Microsoft help doesn't do much for me.
    Here's the code:


    Code:
    Option Compare Database
    
    Private Sub txtScanned_Input_AfterUpdate()
    Dim strInput As String
    strInput = txtScanned_Input
    
      
      Me.lblMessage.Caption = "WAITING ON ENGRAVER"   'Changes Display Message
            
         
                                     
            DoCmd.RunSQL "INSERT INTO tblDOT_PEEN ([2D_DATA], [SCAN_DATE])" & _
            "VALUES (txtScanned_Input, DATE());"                                   'Stores barcode data and scan date
                                                                                   
                                                                                      
                         
            
           [B] MSComm0.CommPort = 1 [/B]                     'Sets communication port to serial port Com1 - Dot Peen
            MSComm0.Settings = "19200,N,8,1,N"             'Declares Dot-Peen settings
            MSComm0.PortOpen = True                         'Opens port for read/write capability
            MSComm0.Output = strInput                       'Initiates marking sequence of 2D barcode
            MSComm0.PortOpen = False
    
        lblMessage.Caption = "CHECKING MARK"
        
    '''''''''''''''
        cmdWAIT
    '''''''''''''''
    
            MSComm1.CommPort = 2                            'Sets communication port to serial com2 - Congnex imager
            MSComm1.PortOpen = True                         'Opens port for read capability
            MSComm1.Input = strInput                        'Passes scanned data to imager
    
                
                If MSComm1.Input = MSComm0.Output Then
                    Me.lblMessage.Caption = "GOOD MARK!"
                Else
                   MsgBox "Bad Mark! Please contact your manager", vbOKCancel, "Marking Error"
                End If
                
    ''''''''''''''
        cmdRESET
    ''''''''''''''
            
              
    End Sub
    
    Public Sub cmdWAIT()
    
    Dim PauseTime, Start, Finish, TotalTime
        
        PauseTime = 2   ' Set duration.
        Start = Timer    ' Set start time.
        Do While Timer < Start + PauseTime
            DoEvents    ' Yield to other processes.
        Loop
    
    End Sub
    
    Public Sub cmdRESET()
    
    strInput = ""
    strDP_Result = ""
    lblMessage.Caption = "LOAD BODY AND SCAN CORE BARCODE"
    
    
    End Sub
    
    
    End Sub


    Any help, tips, links, or info would be greatly appreciated.
    Thanks in advance!
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    So, do you have an object named MSComm0 or not? It looks as though you probably should have an MSComm control on the form with this name.

    Comment

    • dbrother
      New Member
      • Nov 2007
      • 19

      #3
      I was assuming that MSComm was inherent to VBA. It specifically says "Object required", so that would make sense.

      How would I go about putting something such as this on a form? MSComm is the way to open the serial port for communcation between devices. It's not like a textbox or button. Maybe I'm a little confused.


      What would I need to do to put this onto the form?
      Also, could I put this part of the code in it's own sub Method and call it and not receive the object required error?

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        select tools ---> activex control

        and select the desired item form the list.

        Comment

        Working...