Solved OpenMap VBA Code

dgreen

Member
Local time
Today, 05:40
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
 
Hi. Add Call to your code. For example:

Code:
Call OpenMap(...
 
In your function, you are already performing the Nz() so pretty sure you don't need to do it again in your function call.
 
@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

Back
Top Bottom