How can I with MS Access VBA log into a website?

Posted on 2011-03-25
Last Modified: 2012-06-27
I need to be able to log into Youtube with a command button in Ms Access. I have done this with other sites but Youtube i am having a problem. I either dont have the control name right or something else is wrong. I have attached the code, I took out the real user and password.  
Private Sub Command1_Click()
Dim User As String
Dim password As String
Dim site As String
Dim objIE As Object
Dim strSql As String
Dim ClientLoginAddress As String
username = "user"
password = "password"

YouTubeAddress = ""
site = YouTubeAddress
Set objIE = CreateObject("InternetExplorer.Application")
    With objIE
    .visible = True
    .Navigate site
        Do While .ReadyState <> 4
        With .Document.Forms(1)
            .username.Value = username
            .password.Value = password
            End With
    End With
End Sub

Open in new window

Question by:seanlhall
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 30

Accepted Solution

SiddharthRout earned 500 total points
ID: 35221056
You need to refer the controls by their ID's.

Here is the code which is tested and tried :)

Private Sub Command1_Click()
    Dim UserName As String, password As String, YouTubeAddress As String
    Dim objIE As Object
    UserName = "User"
    password = "Password"
    YouTubeAddress = ""
    Set objIE = CreateObject("InternetExplorer.Application")
    With objIE
        .Visible = True
        .Navigate YouTubeAddress
        Do While .ReadyState <> 4
        With .Document
            .getelementbyid("Email").Value = UserName
            .getelementbyid("Passwd").Value = password
        End With
    End With
End Sub

Open in new window


Author Closing Comment

ID: 35261096
Thank you.

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question