Link to home
Start Free TrialLog in
Avatar of Slicer58
Slicer58

asked on

MS Access VBA code to launch Cyberhomes valuation...

Hi.
I need to have a button which will open the Cyberhomes.com website with the property information drawn from my form's controls.
The controls are: Address1, City, State, Zip

The code below works to launch the Google map, but I don't know how to modify it to launch the Cyberhomes valuation...

Thanks!
Private Sub Label41_Click()
     On Error Resume Next
     Me.Refresh
     Access.FollowHyperlink "http://www.google.com/maps?q=" & _
                Replace(Me.Address1.Value, " ", "+") & "+" & _
                Replace(Me.City.Value, " ", "+") & "+" & _
                Replace(Me.State.Value, " ", "+") & "+" & _
                Replace(Me.Zip.Value, " ", "+") & "&sa=X&oi=map&ct=title"
End Sub

Open in new window

Avatar of Chuck Wood
Chuck Wood
Flag of United States of America image

Replace the http link in the line below with the URL (Universal Resource Locator) for the Cyberhomes web site.

"http://www.google.com/maps?q=
Avatar of Slicer58
Slicer58

ASKER

Already tried that because it was so very obvious.  Didn't work.
Does the Cyberhome site work like Google maps, that is does it accept address + city + state + ZIP in the URL?
I believe it's more complex than that, although I can see the address in the URL.  It would make more sense to you if you actually visited the site and then tried the code out yourself.
I would do that but unfortunately my corporate firewall won't let me. Can you post an example of the URL that works?
Here are two URLs from the site:
http://www.cyberhomes.com/homes-tustin-ca-92782/2947playerln/61214815.aspx
http://www.cyberhomes.com/homes-eastorange-nj-07017/160glenwoodave/10371460.aspx

Below is (I believe) an HTTP Post that works from our CRM.  Not sure how it would be translated into a VBA expression for Access 2007:  
http://cyberhomes.com/searchredirect.aspx?address={prop_street}&city={prop_city}&state={prop_state}


You might want to try something like this:

Private Sub Label41_Click()
     Dim strStreet As String, astrAddress() As String
     Dim intAddr As Integer
     ' split the address on spaces
     astrAddress = Split(Me.Address1.Value, " ")
     ' if the first part of the address is numeric
     If IsNumeric(astrAddress(0)) Then
        ' loop through the remaining parts of the address
        For intAddr = 1 To UBound(astrAddress, 1)
            ' add this part to the street
            strStreet = astrAddress(intAddr) & " "
        Next intAddr
     Else
        ' loop through all parts of the address
        For intAddr = 0 To UBound(astrAddress, 1)
            ' add this part to the street
            strStreet = astrAddress(intAddr) & " "
        Next intAddr
     End If
     strStreet = Trim(strStreet)
     On Error Resume Next
     Me.Refresh
    Access.FollowHyperlink "http://cyberhomes.com/searchredirect.aspx?address={" & _
        strStreet & "}&city={" & Me.City.Value & "}&state={" & Me.State.Value & "}"
End Sub

Open in new window

Thanks for going to all that trouble.  I tried it and kept getting error messages where it didn't recognize the fields.  I took out the brackets and that worked for the city and state, but it didn't recognize the street data.  So I pared it down to the following and it works fine.  My only question now is, can you help me split this code into the easy to read lines (I'm not sure where to put the ampersands and quotes).


Private Sub Label30_Click()
     On Error Resume Next
     Me.Refresh
    Access.FollowHyperlink "http://cyberhomes.com/searchredirect.aspx?address=" & Me.Address1.Value & "&city=" & Me.City.Value & "&state=" & Me.State.Value & "&zip=" & Me.Zip.Value & ""
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Chuck Wood
Chuck Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help!
You are very welcome.