Results 1 to 10 of 10
  1. #1
    dniezby is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2013
    Posts
    183

    Question Browser controller from table field?

    So here is the situation: At data input, I want the user to enter a URL for an image. That part is a piece of cake.


    However, on the form for displaying the data I want the user to click a button (to see the image) and it opens a Web control that displays the image. Is there a way to do this?

    Now that I think of it, I guess I need to code the button to pull the data from the field that has the URL and then pass that data to the form it will open.

    Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Paste this code into a module, then its usage is: OpenNativeApp txtBox


    if the item in the text box is a URL, it will open in default explorer
    whatever path is in the textbox will open in its native application




    Code:
    
    #If Win64 Then      'Public Dclare PtrSafe Function
      Private Declare PtrSafe 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 PtrSafe Function GetDesktopWindow Lib "user32" () As Long
    #else
      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
    #End If
    
    
    
    
    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
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you can just assign the url control value to the web control - something like

    me.webcontrol=me.urlcontrol

  4. #4
    dniezby is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2013
    Posts
    183
    Thanks @CJ_London, that was exactly what I was looking for it to do.

    @ranman246 Thank you for your help as well but it was a little more than I needed. It's probably the way I worded the question.

  5. #5
    dniezby is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by CJ_London View Post
    you can just assign the url control value to the web control - something like

    me.webcontrol=me.urlcontrol
    So, I decided to make this happen via a pop-up window. It will go into a "help" window. It's a separate form that the user will open via a button on the original form. I've been away from Access for a while and need a refresher on passing that variable on to the new "help" window.

    This is what I'm thinking right now or am I completely wrong. Again, it's been a while since I had to code Access.
    Code:
    Private Sub Command422_Click()
    Forms![DisplaySeed].Form.[PlantBookPage].Form.DetailsURL = Me.PlantBookURL
    End Sub
    For reference:
    The DisplaySeed form is the name of the main form which has the field DetailsURL on it.
    The PlantBookURL is the Webcontrol form that should get the results from the detailsfield on the other form.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    I don't have your vision for what the app is required to do - so all I can suggest is try it. I don't see anything wrong with the code - I presume you have other code to open the form in the first place

  7. #7
    dniezby is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2013
    Posts
    183
    oops...No I didn't put code in to open the form. I should be able to add it in the Click event right?
    Code:
    Private Sub Command411_Click()
    Form![DisplaySeed].Form.[PlantBookPage].Form.DetailsURL = Me.PlantBookURL
    DoCmd.OpenForm "DisplaySeed"
    End Sub

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    try it - it will fail - you need to open the form before trying to modify it

  9. #9
    dniezby is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2013
    Posts
    183
    Hmm...Okay...I'll keep working on that then. LOL. I have the ideas? I just need to figure out where to put actions then I guess.

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you might find this link helpful for order of events
    https://support.microsoft.com/en-us/...7-ce86553682f9

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open Address Field in Web Browser
    By MatthewGrace in forum Programming
    Replies: 1
    Last Post: 12-26-2016, 09:01 AM
  2. Replies: 9
    Last Post: 11-22-2015, 11:19 AM
  3. Web Browser
    By trini46petes in forum Access
    Replies: 9
    Last Post: 02-24-2015, 12:42 PM
  4. How I can connect access table in browser
    By learning_graccess in forum Programming
    Replies: 1
    Last Post: 04-04-2012, 04:40 PM
  5. Replies: 5
    Last Post: 05-03-2011, 07:55 AM

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