Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I have Access launch a visit to CarFax.com, enter a VIN, read the info and return it?

3 views
Skip to first unread message

MLH

unread,
Jun 3, 2005, 5:53:46 PM6/3/05
to
This is an Access 97 objective...
If one manually goes to carfax.com, enters
the VIN number shown below, the info blurb
under FREE Record Check Results is then
displayed. I would like to read the year, make,
model and body style & return it to Access for
further processing. Is this easy, difficult or
impossible or none of the above?


FREE Record Check Results
VIN: 2C1MR5295S6702239
Year/Make/Model: 1995 GEO METRO/LSI
Body Style: Sedan 4 DR
Engine Type: 1.3L L4 EFI SOHC
Manufactured In: CANADA

MLH

unread,
Jun 3, 2005, 6:04:43 PM6/3/05
to
Actually, here is a better place to do it...

If I feed this URL into IE & launch it...
http://www.autocheck.com/consumers/gatewayAction.do?siteID=956&affid=CDT&vin=2C1MR5295S6702239
... the following appears in the browser window...

We found 6 record(s) for this vehicle

VIN: 2C1MR5295S6702239
Year: 1995
Make: Geo
Model: Metro
Style/Body: Sedan 4 Door
Engine: 1.3L I-4 EFI
Country of Assembly: Canada

Now, I could work with that data blurb much easier. Its already
parsed with CRLF's between each field of interest. The field names
are there already. Pretty much everything I want is there. I just
don't know how to capture it and feed it back to Access.

Suggestions???

windandwaves

unread,
Jun 3, 2005, 7:20:18 PM6/3/05
to

If you can find a way for access to know where the file is saved or to save
it then I can help your read the file and parse it into a table. I just
dont know how Access knows how to access the file.

- Nicolaas


MLH

unread,
Jun 3, 2005, 7:59:38 PM6/3/05
to
No sweat! If you can get this captured written
to a disk file - I can handle it from there. I just
haven't a clue how to locate, snatch & save
the desired lines off the IE browser.

Do me a favor. Save it to c:\temp\datfile.txt

Thx.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

rkc

unread,
Jun 3, 2005, 10:57:10 PM6/3/05
to
MLH wrote:
> No sweat! If you can get this captured written
> to a disk file - I can handle it from there. I just
> haven't a clue how to locate, snatch & save
> the desired lines off the IE browser.
>
> Do me a favor. Save it to c:\temp\datfile.txt


This simple class uses Microsoft.XMLHTTP.
There's a simple test sub below it.

<clsGetPageContent>

Option Compare Database
Option Explicit

Private mPageContent As String

Public Property Get PageContent() As String
PageContent = mPageContent
End Property

Public Sub requestPage(url As String)
On Error GoTo errHandler

Dim msXML As Object

Set msXML = CreateObject("Microsoft.XMLHTTP")
msXML.Open "GET", url, False
msXML.send
mPageContent = msXML.responseText

exitHere:
If Not msXML Is Nothing Then Set msXML = Nothing
Exit Sub
errHandler:
Err.Raise Err.Number, , _
"Error retrieving data from " & vbCrLf & url & vbCrLf & Err.Description
Resume exitHere
End Sub

Public Sub savePage(path As String)
Dim fh As Long

On Error GoTo errHandler

fh = FreeFile
Open path For Output As #fh
Print #fh, mPageContent
exitHere:
Close #fh
Exit Sub
errHandler:
Err.Raise Err.Number, , _
"Error writing to: " & path & vbCrLf & Err.Description
Resume exitHere

End Sub

</clsGetPageContent>

<test>

Sub test()
Dim gpc As clsGetPageContent
Set gpc = New clsGetPageContent

gpc.requestPage "http://www.autocheck.com/"
gpc.savePage "c:\temp\datfile.txt"

Set gpc = Nothing
End Sub

</test>

MLH

unread,
Jun 4, 2005, 10:09:48 AM6/4/05
to
Help me out a bit here, I'm unfamiliar with the


<clsGetPageContent>
...
</clsGetPageContent>


usage. Is that syntax for creation and setup
of a user-defined type? Should I put everything
between those 2 strings in a global module, or
will a form module do?

Trevor Best

unread,
Jun 4, 2005, 10:31:30 AM6/4/05
to

clsGetPageContent would be the name you give to the class module

--
[OO=00=OO]

MLH

unread,
Jun 4, 2005, 10:45:52 AM6/4/05
to
I'm sure that somewhere, I'll have to define
the clsGetPageContent User Defined Type.
Help me out here, something like...


Public Type clsGetPageContent
var1 As Variant
var2 As Long
var3 As Integer
var4 As Currency
var5 As Variant
End Type


... I would imagine.

rkc

unread,
Jun 4, 2005, 2:59:19 PM6/4/05
to
MLH wrote:
> Help me out a bit here, I'm unfamiliar with the
>
>
> <clsGetPageContent>
> ...
> </clsGetPageContent>

Sorry, that's just my lameass way of indicatiing the start, end
and name of code that belongs in the same class or code module.

Copy the text between the two markers above and paste it into a
class module. Save it and name it clsGetPageContent.

Copy and paste the text between the other two markers into a
code module. Place the cursor at the beginning of the Sub test()
method and hit F5 to run it. You should end up with a
c:\temp\datfile.txt file with the contents of the web page at
http://www.autocheck.com/

Bookreader

unread,
Jun 4, 2005, 5:28:05 PM6/4/05
to

I know that this is an Access forum, but would this be the same in VB
6?

Thanks.

rkc

unread,
Jun 4, 2005, 11:06:05 PM6/4/05
to
Bookreader wrote:

> I know that this is an Access forum, but would this be the same in VB
> 6?

Yes indeed. Do a search on Microsoft.XMLHTTP and you will find many
examples.

MLH

unread,
Jun 5, 2005, 12:26:21 AM6/5/05
to
Sorry, it tells me the user defined type is not defined
when I run Sub test().

Dim gpc As clsGetPageContent is the problematic
line.

rkc

unread,
Jun 5, 2005, 5:44:39 AM6/5/05
to

Did you put the clsGetPageContent code in a class module
named clsGetPageContent?
Not a module. A Class module.

If you're really stumped by this, just do a Google search
for Microsoft.XMLHTTP.

MLH

unread,
Jun 5, 2005, 11:18:09 AM6/5/05
to
I pasted the code in a form module and saved the form
as that name. When I view the code in the form module,
the header bar at the top says
"Form_clsGetPageContent : Class Module"

Is that how I was supposed to create the class
module???
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

rkc

unread,
Jun 5, 2005, 12:07:30 PM6/5/05
to
MLH wrote:
> I pasted the code in a form module and saved the form
> as that name. When I view the code in the form module,
> the header bar at the top says
> "Form_clsGetPageContent : Class Module"
>
> Is that how I was supposed to create the class
> module???

O.K. Forget the class. Put the following in a click
event of a button on a form and click the button.


'---------
Dim msXML As Object
Dim strPageContent as string
Dim fh as Long

fh = Freefile

Set msXML = CreateObject("Microsoft.XMLHTTP")

msXML.Open "GET", "http://www.autocheck.com/", False
msXML.send
strPageContent = msXML.responseText

Open "c:\temp\datfile.txt" for Output as #Freefile
Print #fh, strPageContent

set msXML = Nothing
Close #fh
'---------


Tom

unread,
Jun 5, 2005, 1:43:04 PM6/5/05
to
You can get Make, Model and Engine here. Do you know of any websites that
can take that information and give you fluid capacities such as Oil,
Transmission fluid, Brake fluid and Differential fluid?

Thanks!

Tom

"MLH" <CR...@NorthState.net> wrote in message
news:bqk1a1duanvhgvl1s...@4ax.com...

MLH

unread,
Jun 5, 2005, 2:16:41 PM6/5/05
to
You got me. That would be a nice site, now wouldn't it?
Might generate a lot of traffic.

MLH

unread,
Jun 5, 2005, 2:26:46 PM6/5/05
to
Now that's what I'm talking about.
And whew - how fast it is!

Sorry I couldn't figure out the stuff
regarding the class module you gave
me the first time. Just now making
the leap from Access 2.0 to 97.
Dunno much about class modules
yet. But U fixed my prob - that's
for sure. Man, you're a genius.

MLH

unread,
Jun 5, 2005, 3:08:18 PM6/5/05
to
rkc: Would it be simple to paste the string onto
the Windows clipboard, rather than writing it to
disk? I could manipulate it from there just as
easily and not have to bother the disk at all.

MLH

unread,
Jun 5, 2005, 3:10:23 PM6/5/05
to
What I'm really trying to accomplish here is to
write the text snip to a string var in Access 97
for processing. I know I can set a text var
equal to the contents of a text file. But setting
to the value of a string of text on the clipboard
is much less messy.

Thx.

rkc

unread,
Jun 5, 2005, 3:48:39 PM6/5/05
to


Here's a break down of the parts of the code you need to
understand.

'declare an variable of type object
Dim msXML As Object

'declare a variable of type string
Dim strPageContent as string

'create an XMLHTTP object


Set msXML = CreateObject("Microsoft.XMLHTTP")

'open a connection and send a request for a web page
'via two methods of the XMLHTTP object


msXML.Open "GET", "http://www.autocheck.com/", False
msXML.send

'a successful request returns the page content and the
'XMLHTTP object stores the content in it's responseText
'property.
'here the responseText is stored in the local strPageContent
'variable so the XMLHTTP object can be desposed of
strPageContent = msXML.responseText

'despose of the XMLHTTP object
Set msXML = Nothing


You now have a string variable with the entire contents of
the web page in memory. Assuming you understand the concept
of variable scope, you can do whatever you want with it.
You don't have to write it to a file. You don't need to fuss
with the clipboard to manipulate it. Just use it.

In this case you will need to search the variable for the
text you want to display. It turns out the section of the
file you're looking for is de-limited by comment tags.

<!--START VEHICLE DESCRIPTION-->
<!--END VEHICLE DESCRIPTION-->

Hope you understand that.
Good luck with the rest of the task.

MLH

unread,
Jun 5, 2005, 5:19:50 PM6/5/05
to
RKC - U R the man.
I did exactly what you said.
Those beginning and ending markers did the trick.
I was so happy that your code worked, I didn't even
bother to look at it to see that you were assigning the
page contents to a var before writing it to a file. That's
the ticket. I'll work with it there, never even writing it
to a file. Thx again!
0 new messages