As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Need help with MS Access 2010/VBA coding

Liquid HellzLiquid Hellz Registered User regular
edited January 2012 in Help / Advice Forum
Hey guys and gals I have an Access database with a button that I hit to map addresses, it used to work when I was using MS Access 2007(which is what the database was built in) and Windows Vista 32 bit. I recently upgraded to Windows 7 64 bit and MS Access 2010.
Option Compare Database
Option Explicit

Function OpenMap(Address, City, State, Zip)

    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)
    
    If strAddress = "" Then
        MsgBox "There is no address to map."
    Else
        Application.FollowHyperlink "http://maps.google.com/maps?q=" & strAddress
    End If
End Function

The Embedded macro is
RunCode
Function Name OpenMap([Address],[City],[State],[Zip])

Im not even sure Function Name or OpenMap is legitimate to use in Access 2010?

Pretty basic I guess. I didnt create this macro or module, just copy and pasted everything from an example database back when I built this database in access 2007. But now when I hit the button it says "The expression you entered has a function name Microsoft Access cant find"

It then opens a window called macro single step and says

Macro Name: Wind Mitigation Pictures : cmdMap : OnClick : Embedded Macro

ActionName: RunCode

Arguments: OpenMap([Address],[City],[State],[Zip])

Error Number: 2425

The module name is OpenMap

When I run the debug nothing comes back at all... Any help or insight would be greatly appreciated, thanks!

What I do for a living:
Home Inspection and Wind Mitigation
http://www.FairWindInspections.com/
Liquid Hellz on

Posts

  • Options
    KatoKato Registered User regular
    Just asking...but did you go in to the options and click that it is compatible or whatever with earlier databases? 2010 has a different set of rules or something that varies from databases made in 2007 and before. Man...I could be extremely wrong on this too. Sorry...just trying to provide you with something to at least check in too.

    Signature??
  • Options
    Liquid HellzLiquid Hellz Registered User regular
    Well I thought Access 2007 and 2010 were practically the same as far as compatibility. I think 2010, is 2007 with some minor upgrades. When I try to create a new database with 2010 it opens and at the top it says Database (Access 2007). Not real sure either tho..

    What I do for a living:
    Home Inspection and Wind Mitigation
    http://www.FairWindInspections.com/
  • Options
    schattenjaegerschattenjaeger Registered User regular
    Yah that shouldn't be the problem.

    There is an immediate problem with the code you copied, you have a semicolon outside the quotes there on the followhyperlink call. Is that actually like that in your code?

    Second, I don't quite understand why you have this

    Function Name OpenMap([Address],[City],[State],[Zip])

    Try getting ride of Function Name and just having OpenMap(blahblahblah)

    I think all you're doing there is calling the function, which you do by typing the function name. Not literally "Function Name"

  • Options
    Liquid HellzLiquid Hellz Registered User regular
    Sorry, the function name part is not in my code its the action part of the macro tool or whatever you wanna call it. Hmm thats weird, the semicolon is not actually there in the code but got added with the copy/paste somehow.

    What I do for a living:
    Home Inspection and Wind Mitigation
    http://www.FairWindInspections.com/
Sign In or Register to comment.