Solved

Opening a website and submit a value to a specific field in access 2016

Posted on 2016-10-01
10
78 Views
Last Modified: 2016-10-11
I'd like automate the process of opening a web page, submit a tracking number and run the page to get the status in Access 2016 vba via a click event of a button. Attached is how the tracking webpage is like. Any help is appreciated.
tracking-page.JPG
0
Comment
Question by:thao-nhi
10 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 41825158
It depends on the tracking site and how much JavaScript is involved.

A normal HTML form can be queries by using MSXML2.XMLHTTP with the appropriate POST form variables.
Otherwise you need a WebBrowser control and automate it.
0
 

Author Comment

by:thao-nhi
ID: 41825295
Could you help further with examples of webbrowser control to post the tracking number and get the result? Thanks
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41825297
Not as long I don't know that site. Cause it solely depends on it.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20
ID: 41825650
UPS? FedEx? USPS? Something else? As ste5an said, it depends on what site you are using
0
 

Author Comment

by:thao-nhi
ID: 41825653
Canada post is the site.
0
 

Author Comment

by:thao-nhi
ID: 41825655
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41826185
First of all: Your previous screen shoot is completely different then what I see on www.canadapost.ca.

CAVEAT: I don't know whether it is legal use of that site to do this (IANAL).

But just take a look at the tracking form:

<form enctype="application/x-www-form-urlencoded" action="/cpotools/apps/track/personal/findByTrackNumber" method="post" name="widgetForm" id="widgetForm">
	<label for="csho" class="visually-hidden">Enter the Number</label>
	<select class="csho" id="csho" data-placeholder="Select Your Options">
		<option value="tracknumber" selected="selected">Tracking number</option>
		<option value="deliverynotice">Delivery notice card number</option>
		<option value="referencenumber">Reference number</option>
	</select>

	<label for="trackingNumber" class="visually-hidden">Enter the Number</label>
	<input type="text" placeholder="Example: 23476542897" id="trackingNumber" name="trackingNumber" title="Enter the Number" />
	<span class="searchpipe">&nbsp;</span>
	<div class="searchButton">Find</div> 
	<div class="tracknumber">
		<span class="trackingText">
			Enter up to 24 tracking numbers, separated by commas
		</span> 
	</div>

	<div class="referencenumber">
		<div class="outsideref">
			<span class="trackingText">
				Enter up to 24 numbers, separated by commas
			</span>
			<div class="row">
				<div class="large-6 medium-6 small-6 columns">
					<label for="dateFrom" style="visibility: hidden;">Date From</label>
				</div> 
				<div class="large-6 medium-6 small-6 columns">
					<label for="dateTo" style="visibility: hidden;">Date To</label>
				</div>
			</div>  
			<div class="row"><!--ct-->
				<div class="large-6 medium-6 small-6 columns">
					<input type="text" class="radius" value="" id="dateFrom" placeholder="Date From">  
				</div> 
				<div class="large-6 medium-6 small-6 columns">
					<input type="text" id="dateTo" value="" class="radius" placeholder="Date To">
				</div>
			</div>
		</div>                       
	</div>

	<div class="deliverynotice">
		<span class="trackingText">
			Enter up to 24 tracking numbers, separated by commas
		</span> 
	</div>
	<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
</form>

Open in new window


So just send a post request to /cpotools/apps/track/personal/findByTrackNumber where the parameter name is trackingNumber and the value URL encoded.

As an exercise for you and to help to understand what you need to do: Use Fiddler to see the corresponding HTTP traffic.
0
 

Author Comment

by:thao-nhi
ID: 41829025
Thanks for the help but so far I still have no idea how to go about this.
0
 
LVL 33

Assisted Solution

by:ste5an
ste5an earned 250 total points
ID: 41829468
Have you installed Fiddler? Then use it and send a tracking request on that site. Evaluate the HTTP(S) traffic in Fiddler. Look for the form submit. This is the request you have to replay by using MSXML-XMLHttp.
0
 
LVL 40

Accepted Solution

by:
als315 earned 250 total points
ID: 41830380
Look at sample. Enter tracking number and press Dowload. You will se result in window
Capture-Web-Data.accdb
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question