Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28

    Opening a specific form view from an external link


    I have 4 forms in my access file. Now I have 4 buttons in html and I wanted to know if there was a way to open a specific form view based on the button click in the html page.
    So access will open and show the form that is linked to the selected button in html.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Paste the code below into a module.
    Then to open ANYTHING, (word docs, excel, html page) just pass it the path:

    OpenNativeApp "c:\myfolder\stuff.doc"
    'will open in word

    OpenNativeApp "www.google.com/"
    'will open in a web browser


    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    
    
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    
    
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    ranman, OP wants to open Access from html code document (a web page?). And also wants to open a particular form based on parameter from the html. Both of which are over my head.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    if HTML , then the code will open the web page.

  5. #5
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Opening access is not the issue, the issue is opening it in a particular form view. For example imagine you have 4 forms in that access file. I want to be able to open this access file and have form1 show up right away when user click on link1, form2 show up right away on click of link2, etc...

    Maybe there is a way to call a script which will open access in a certain way, not sure.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    A script can open db with a switch that runs a macro. Macro can open form. However, I don't know any way to pass a value that can be evaluated as a condition for opening a particular form. https://www.accessforums.net/macros/...cro-52400.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Quote Originally Posted by June7 View Post
    A script can open db with a switch that runs a macro. Macro can open form. However, I don't know any way to pass a value that can be evaluated as a condition for opening a particular form. https://www.accessforums.net/macros/...cro-52400.html
    Yeah I'll need some sort of a value to define which form to open...

  8. #8
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Can I create an external script file where I can call my access file and write a code with something like: DoCmd.OpenForm FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs in order to open that specific form? Or can this be done just in access?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Can you have the DoCmd.OpenForm within the script file - I don't think so. Can have a form set to open by default in Access or have an AutoExec macro that will automatically run when db is opened, neither of which resolves the issue of passing parameter to the db.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Quote Originally Posted by June7 View Post
    Can you have the DoCmd.OpenForm within the script file - I don't think so. Can have a form set to open by default in Access or have an AutoExec macro that will automatically run when db is opened, neither of which resolves the issue of passing parameter to the db.
    What about creating a script file for each button, for example Script1 will open Form1, Script2 will open Form2, etc... Then I can link each external button to a specific script which will only be need to open one specific form view. So no need to variable passing.

    Will that be something that can be done and if so what would be the code in the script and what file format would the script file be?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Script can open db with a switch that runs macro.

    So I guess 4 scripts would get you want you want. Or one script with conditional code that prompts user to make choice. What 'external' buttons where?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Each button is a url link to the access file. So I am planing on have the buttons open the link to the script. I am using the buttons in Adobe Captivate...

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Okay, let us know how that goes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by T_Tronix View Post
    Each button is a url link to the access file. So I am planing on have the buttons open the link to the script. I am using the buttons in Adobe Captivate...
    Can you post the code that you are using to open Access from the web page? There may not be a need to use script. However, crazy things can happen when a web browser asks to do certain things on the client machine.

  15. #15
    T_Tronix is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    28
    Quote Originally Posted by ItsMe View Post
    Can you post the code that you are using to open Access from the web page? There may not be a need to use script. However, crazy things can happen when a web browser asks to do certain things on the client machine.
    There is not much code its a plain onclick go to url...Where can I find a sample code for an external script file that will open an access file and then show the form via macro? I've never coded an external script before for access...

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2015, 12:59 AM
  2. Replies: 2
    Last Post: 01-14-2015, 12:00 PM
  3. View only specific records in form view
    By drnld in forum Access
    Replies: 5
    Last Post: 07-22-2014, 12:21 PM
  4. Replies: 9
    Last Post: 10-09-2013, 08:45 AM
  5. Open an external folder specific by a form field
    By AccessNoob16 in forum Forms
    Replies: 11
    Last Post: 04-09-2012, 01:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums