Results 1 to 6 of 6
  1. #1
    aliendb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2021
    Posts
    3

    Web Browswer Control - Action after successful login

    Hello all - thank you for taking the time to review.

    I've been reading some other posts on using a Web Browswer Control or ActiveX Windows Browser and hope someone can get me on the right path. I am building a submission form that will be tied to a Sharepoint site but in order for the data to submit, you obviously have to be logged into the site. I want to use the Web Control on the form to enable the user to log in from the Access file, and my hope, is to allow the program to simply hide the login form once the user successfully enters their data - - once logged in, the user can submit their information which will be stored to the Sharepoint Site.
    I've created a splash page on sharepoint to indicate "login successful" and I'm trying to figure out the best way to read this information on the changed state of the web-browser - which would either unhide the "continue" option from Access and open the form to enter data or... once the state is TRUE, it would just hide the form and open the submission...
    I'm looking for the best way to have Access in a continuous "read/wait" state until the browser successfully loads the splash page... This is where I am stuck. Attached image is just the screen shots of the login process and the splash page that opens from within the web browser (and the div class where the LOGIN SUCCESSFUL text is situated..

    I'm not sure which event is the best location for code to monitor the wait state, looking for changes in the web browser (on focus, got focus, etc...)
    Click image for larger version. 

Name:	access_login_process.jpg 
Views:	17 
Size:	116.0 KB 
ID:	44898


    any assistance is appreciated...

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Not sure, but it seems that you're saying you want something to happen in Access when the browser control contains the url of a successful login to Sharepoint.
    Or is it that you want Access code that is being executed to "hold" until the successful login but also how to determine that a user is logged in to SP?
    I suppose the hold part would be to call a function that loops until the browser object url is the logged in url. How you tell that I don't know. Did you look here at the events list for the control?

    https://docs.microsoft.com/en-us/office/vba/api/access.webbrowsercontrol

    Perhaps AfterUpdate, DocumentComplete or Updated.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    aliendb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2021
    Posts
    3
    Thanks for the reference. I will read through and see what I might be able to fashion.

    But yes, basically I need to have a user log into the SharePoint site in order for the linked tables to read the data. I used to have a separate window open, log in, minimize the SharePoint browser, to then allow the access file to do what it is supposed to...

    After finding some writeups on this control, it seems like I should be able to essentially do the same but all within the access file... I am just not to familiar with using access properties of the controls in VBA...

    Either one of your examples essentially is what I would need it to do... loop a function that evaluated the state of the window... if the login worked... then the code would know it is correct because it reads the login successful... then the loop exits and continue as needed... sometimes this window login gives a bad connection (a BIG-IP timeout)... the user can still manually navigate from this window to reload and try again... until login successful.

    I was trying to use the getElementByID, but I am just not seeing the right properties on the controls... doesn't like me...

    Cheers

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I'd probably do this loop in the timer event, setting the interval to 1000 (1 second) or so, and then 0 when the logged in url is loaded - assuming the logged in url can be read as one of the browser control properties. If you don't impose some control on the frequency of the loop you'll do thousands of iterations every second. Likely that would impose a big load on pc resources.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Seems that DocumentComplete might be all you need for testing the url
    Code:
    Private Sub WebBrowser10_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
    If URL = "logged in url here" then
      do stuff
    End If
    
    End Sub
    If your url will be different for each user, then use a string function to test whichever portion makes the most sense.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    aliendb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2021
    Posts
    3

    Thumbs up SOLVED - Web Browser ActiveX recognition!

    Quote Originally Posted by Micron View Post
    Seems that DocumentComplete might be all you need for testing the url
    Code:
    Private Sub WebBrowser10_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
    If URL = "logged in url here" then
      do stuff
    End If
    
    End Sub
    If your url will be different for each user, then use a string function to test whichever portion makes the most sense.

    Micron! Thank you for the discussion - It seems to work and do the trick... so since i'm not capturing any of the field data within the browser and ONLY using it to confirm if the user log's in... this worked well. I threw in an IF ELSE to force it to retry the login if for some reason the system faults and tries to log into the users personal sharepoint page... seems to happen once in a while but with the ELSE re-loading the same page on OPEN - it worked well. Turns out if the user tries to navigate anywhere within the web control - this DOCUMENTCOMPLETE option forces the browser to reload to the pre-determined option... you basically can't do anything else.

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    if URL = "url here to main page" THEN
    msgbox "happy days - it worked on first try"

    else

    me.webrowser1.object.navigate "url here to main page"
    msgbox "personal message that this was on the second attempt"

    end if

    now I can run the open new form and hide current form options.
    end sub

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

Similar Threads

  1. Upon Successful Login Change AFRs Form Version
    By billgyrotech1 in forum Access
    Replies: 26
    Last Post: 06-21-2019, 01:55 PM
  2. Related Tables, Form, Changes not successful
    By msto in forum Database Design
    Replies: 5
    Last Post: 04-25-2019, 02:06 PM
  3. Replies: 14
    Last Post: 08-10-2018, 02:30 AM
  4. Replies: 7
    Last Post: 08-17-2015, 11:52 PM
  5. Control to get login but store id to table
    By nmart1230 in forum Forms
    Replies: 57
    Last Post: 11-19-2014, 08:29 PM

Tags for this Thread

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