Web Page Opening

As June7 has mentioned in the other post, concatenate your varaiables with the string required,
In the example one would be message which is already being concatenated. I would be using & though.


Something along the lines of
Code:
Public Function SendSMS_Text(message As String, number As String)
Dim message As String
Dim result As String
Dim myURL As String, postData As String
Dim winHttpReq As Object
message = "Hello this is a test message."
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
myURL = "http://sendpk.com/api/sms.php"
postData = "username=923xxx&password=xxx&messsge=" & message & _
"&mobile=" & number & "&mask=BrandName&format=xml"
winHttpReq.Open "POST", myURL, False
winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
winHttpReq.Send (postData)
SendSMS_Text = winHttpReq.responseText
Set WinHttpReq = Nothing

End Function
then in your form
Result = SendSMS_Text(Me.Message,Me.Number)


As for speed, I'd try changing the code so that you send all the message in one creation of the WinHttpReq object, rather than creating/releasing each time, but as we do not know how your system is structured, it is hard to say.


This is all code I have not used before, so no knowledge. I would be in 'try and see' mode

how to call this function please elloborate i am stuck with it
 
Put a button on your form and call it from the click event of the button.
 
how to call this function please elloborate i am stuck with it

Great i got it and its working.. one thing is making trouble that when clicking command button it takes almost 1-2 minutes to work means it is sending sms but the whole database stuck for 1-2 minutes and you cant open close anything.. any idea for this..
 
Put a button on your form and call it from the click event of the button.

Thanks i created a command buddon and put this on on click event everything is ok but when i click this it tooks almost 20 seconds to clear and during this i cannot click anywhere in access DB means showing busy.. or taking time is there any way to speed this up..
 
No, not really.
Post the code that calls the function and the function as well if you have modified it.
Please post code within code tags.
 
No, not really.
Post the code that calls the function and the function as well if you have modified it.
Please post code within code tags.

Thanks for your time really!!
here is the code...

Code:
Public Function SendSMS_Text(message As String, number As String)

Dim myURL As String
Dim winHttpReq As Object


message = Forms!send_sms.message
number = Forms!send_sms.number

Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
myURL = "http://sendpk.com/api/sms.php"
postData = "username=92xx&password=xxx&sender=BrandName&mobile=" + number + "&message=" + message + "&mask=BrandName&format=xml"""

winHttpReq.Open "POST", myURL, False

winHttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
winHttpReq.send (postData)

End Function
--------------------------------------------------
I am calling like this ..
Code:
Private Sub Command14_Click()
Call SendSMS_Text(Me.message, Me.number)
End Sub
 
Last edited by a moderator:
I asked within code tags? ::banghead:

You are meant to be passing the message and number, yet you directly use the form control values? use one or the either.
You are not releasing the WinHttpReq object before exiting the function. I know some people say it is released anyway, but I have seen cleanup so often, I follow that method.
You do not test the result.? That is why I suggested a function, also I did not put any error code in, you might want to.?

As for speeding it up, I can't help with that, sorry.

I spotted an error as well, if using the passed parameters, remove the Dim message statement.
 
I asked within code tags? ::banghead:

You are meant to be passing the message and number, yet you directly use the form control values? use one or the either.
You are not releasing the WinHttpReq object before exiting the function. I know some people say it is released anyway, but I have seen cleanup so often, I follow that method.
You do not test the result.? That is why I suggested a function, also I did not put any error code in, you might want to.?

As for speeding it up, I can't help with that, sorry.

I spotted an error as well, if using the passed parameters, remove the Dim message statement.


Thanks for your precious Time dear..

I am telling you the fact that i have changed some thing in the code through immense googling... i am such a newbie in vba that i cant write cant edit thats why you .. :banghead: bcz i didnt got what you actually looking for.. it we really pleasure trip if you kindly write again for with error option if need or also tell me that i am doing right with form fields .... or its a wrong way and causing vba to slow..

Thanks in advance.. i will offer you dinner once you here in my country... :D
 
Thanks for your precious Time dear..

I am telling you the fact that i have changed some thing in the code through immense googling... i am such a newbie in vba that i cant write cant edit thats why you .. :banghead: bcz i didnt got what you actually looking for.. it we really pleasure trip if you kindly write again for with error option if need or also tell me that i am doing right with form fields .... or its a wrong way and causing vba to slow..

Thanks in advance.. i will offer you dinner once you here in my country... :D

Somebody told me about asynch option would that help ?
 
I've no idea about the async operation.
To use the code tags, press the # symbol in the mesage window
Code:
and then copy and paste the code between the two tags that are created by the # symbol being pressed.
 

Users who are viewing this thread

Back
Top Bottom