Solved OpenMap VBA Code (1 Viewer)

dgreen

Member
Local time
Today, 17:50
Joined
Sep 30, 2018
Messages
397
Having issues getting this code to compile. I have the module from the Access "Contacts" Database Template behind it. It's likely something simple.

The error is "Expected: ="

Troubleshooting:
1) I've put real values in quotes. Same error.

Code:
Openmap(Nz(Me.Address, ""), Nz(Me.City, ""), Nz(Me.State, ""),Nz(Me.ZIP_Postal_Code, ""), Nz(DLookup("[Country]", "[t_Country]", "[Country_Auto]=" & Nz(Me.Country, 0)), ""))

Code:
Option Compare Database
Option Explicit
Function OpenMap(Address, City, State, ZIP, Country)
    Dim strAddress As String
strAddress = Nz(Address)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(City)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(State)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(ZIP)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(Country)

If strAddress = "" Then
MsgBox "There is no address to map."
Else
Application.FollowHyperlink "http://maps.live.com/default.aspx?where1=" & strAddress
End If
End Function
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:50
Joined
Oct 29, 2018
Messages
21,358
Hi. Add Call to your code. For example:

Code:
Call OpenMap(...
 

Minty

AWF VIP
Local time
Today, 22:50
Joined
Jul 26, 2013
Messages
10,355
In your function, you are already performing the Nz() so pretty sure you don't need to do it again in your function call.
 

dgreen

Member
Local time
Today, 17:50
Joined
Sep 30, 2018
Messages
397
@theDBguy Thanks. Call allowed the code to compile. I'll test it out once my SharePoint backend tables come back online.

@Minty Yeah, I had noticed that as well.
 

Users who are viewing this thread

Top Bottom