Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object variable or With Block variable not set

Status
Not open for further replies.

Rich7638

Technical User
Apr 14, 2005
13
US
I am trying to get MSComm based communications routines running in my Access VBA code:

Private Sub Form_Load()
On Error GoTo load_error

Dim MSComm1 As MSComm

' Open the serial port
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True


If bolToolsOn Then
Command107.Visible = True
Command31.Visible = True
Command32.Visible = True
Command70.Visible = True
End If

load_exit:
Exit Sub

load_error:
MsgBox Err.Description
Resume load_exit

End Sub

When it runs, I get the above listed error (91) with the MSComm1.CommPort = 1 line highlighted.

Any ideas?

Thanks
Rich
 
You must have a MSComm control in your form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Never used this, but if it behaves as any other object that you DIM, you may need to instantiate it with a SET objectname = NEW object

I have great faith in fools; self-confidence my friends call it.
-Poe
 
Thanks PHV,

Once I put the control in the form and removed the DIM statement, I no longer get the error.

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top