Oblect Variable Not Set

D

DS

I keep getting this Error...Object Variable or With Variable Not Set......

Could it be a Timing Issue???....Or?

I'm simply looking to see if I have an Actve Internet connection. And if
not then form closes.

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
Dim WinHttpReq As WinHttp.WinHttpRequest
Dim postVars As String

WinHttpReq.Open "POST", "https://demo.payjunction.com/quick_link", False

WinHttpReq.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"

WinHttpReq.Send postVars

Set WinHttpReq = New WinHttpRequest
postVars = ""
Me.TxtTranType = "AUTHORIZATION_CAPTURE"
Me.TxtSwipe.SetFocus
Exit_Form_Open:
Exit Sub

Err_Form_Open:
MsgBox Err.Description
DoCmd.Close acForm, "frmPadPreAuth"
Resume Exit_Form_Open
End Sub


Any help appreciated. Thanks.
DS
 
J

Jim Burke in Novi

Looks like you just need to move the SET statement:

Set WinHttpReq = New WinHttpRequest

to the beginning of the sub, before the .Open. You're trying to use the
object (Open, SetRequestHeader, etc) before you create an instance of it.
Also, once your done with it you should clean up - Close it (I've never used
one of these and don't know hw they work, but I'm assuming if you Open it you
should also Close it) and set it to Nothing:

WinHttpReq.Close
Set WinHttpReq = Nothing

If you need it to stay open after this routine exits, then I'm not sure how
it would get 'cleaned up'.
 
D

DS

Thank you, I took your advice and set it to nothing, The close property
doesn't seem to work though.
Thank You
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top