Link to home
Start Free TrialLog in
Avatar of ltrain2015
ltrain2015

asked on

MSCOMM and Access 2000

I am having a problem.  I am trying to use MSCOMM to connect and read from a serial port but my program won't run because of the following error.

**************************************
Runtime Error '91'.

Object Variable or With Block Variable not Set
**************************************

Here's my code:

If tglPortStatus.Caption = "Port Closed" Then
        Dim msComm1 As MSComm
        Dim i As Integer
     
        ' Set MSComm = New MSComm
        ' Buffer to hold input string
        Dim Instring As String
        ' Use COM1.
        With msComm1
            .CommPort = 1
            ' 9600 baud, no parity, 8 data, and 1 stop bit.
            .Settings = "9600,N,8,1"
            ' Tell the control to read entire buffer when Input
            ' is used.
            .InputLen = 0
            ' Open the port.
            .PortOpen = True
        End With
        ' Wait for data to come back to the serial port.
        Do
           DoEvents
           Buffer$ = Buffer$ & msComm1.Input
           MsgBox Buffer$
        Loop Until txtReading1.Text <> "" Or Not IsNull(txtReading1)
        ' Close the serial port.
        msComm1.PortOpen = False
        Set msComm1 = Nothing
    End If
Avatar of flavo
flavo
Flag of Australia image

You'll need to uncomment

' Set MSComm = New MSComm

and replace it with

Set msComm1 = New MSComm

Idea?

Dave :-)
Avatar of ltrain2015
ltrain2015

ASKER

OK,

When I try that I get:

*****************************
Run-time Error '429'

ActiveX component can't create object
*****************************

Any other suggestions?
Hmm... I got it working...

I think that error is because its not registered...

Try regeristing the OXC using regsvr32

Open the DOS prompt (type cmd in the Run under the start menu)

Type
cd\
regsvr32 c:\pathToControlFile\file.ocx


Dave
I am having problems with licensing for the mscomm control.  is there anyway to get around it?

Letron
Do you have admin rights on your PC?
Yes, I have domain admin rights.

I tried to add the MSCOM control a different way.

I opened a form in Access 2003 and tried to add the Microsoft Communications Control from the toolbox.  When I did that, it gave me the following message:

***************************************************************************************
You don't have the license required to use the ActiveX control.

You tried to open a form contatining an OLE object or an ActiveX control or you tried to create an ActiveX control.

To obtain the appropriate license, contact the company that provies the licensed OLE object or ActiveX control.
***************************************************************************************

How do I even go about licensing?  Or is there a back door around it?
Im not too sure?  Maybe my copy came from installing VB 6.0?
You may be on to something.  I just grabbed VB6 from the software stash.  I am going to install it and see what happens.  I'll let you know.
Ok, that worked.  I was able to put the control on my form.  So I guess VB6 licenses the control for you.  So if I wanted to run my access app on another pc, would I need to create an app package which includes my access file.  Would the installation correctly register the mscomm control?
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks dude.  Looks like I'm in business.
woo! Finally got there :-)

Good luck with the rest of your project mate!

Dave