Results 1 to 13 of 13
  1. #1
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11

    Automating an online enrollment


    i am looking to run a command that will automate a line of code for each record in my database.

    i need each record in my table "data" run this command(without outside quotes): "Application.FollowHyperlink Address:="https://www.dell.com/support/Assets-Online/us/en/blahblah/#/product-list?servicetag=" & [service tag#]"

    if possible with a 3 or so second delay in between each one, and also if possible in the same window.

    i would assume that there will be some type of "For each" command, i just don't know how to implement.

    Thanks in advance for the help!
    -David

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    something like

    Code:
    dim rst as dao.recordset
    
    set rst=currentdb.openrecordset(SELECT * FROM myTable, dbopensnapshot)
    while not rst.eof
        Application.FollowHyperlink Address:="https://www.dell.com/support/Assets-Online/us/en/blahblah/#/product-list?servicetag=" & [service tag#]
        waitFor 3
        rst.movenext
    wend
    not sure what you mean by 'in same window'

    code to wait for a few seconds -
    Code:
    Function waitFor(NumberOfSeconds As Variant)
    Dim start As Variant
        
        start = Timer
        Do While Timer < start + NumberOfSeconds
            DoEvents
        Loop
     
    End Function

  3. #3
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11
    Thank you!
    could i run this from a query as well?
    also as-is it's giving me a compile error "expected: expression" i changed "mytable" to "data"(name of table)


    this is what is currently in the window:
    Code:
    Function waitFor(NumberOfSeconds As Variant)Dim start As Variant
        
        start = Timer
        Do While Timer < start + NumberOfSeconds
            DoEvents
        Loop
     
    End Function
    
    
    Option Compare Database
    
    
    Private Sub Command0_Click()
    Dim rst As dao.Recordset
    
    
    set rst=currentdb.openrecordset(SELECT * From data, dbopensnapshot)
    While Not rst.EOF
        Application.FollowHyperlink Address:="https://www.dell.com/support/Assets-Online/us/en/blahblah/#/product-list?servicetag=" & [service tag#]
        waitFor 3
        rst.MoveNext
    Wend
    
    
    End Sub

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    sorry, written in a hurry, should be

    set rst=currentdb.openrecordset("SELECT * From data", dbopensnapshot)

    Also your 'option compare database' needs to be at the top of the page, not halfway down

    As to running from a query, possible but not sure what effect the timer will have -all depends on what data you are passing. At the moment your hyperlink will be going to the same place each time

  5. #5
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11
    ok i have made the changes, however, now when it runs it comes up with the error: "Microsoft Access can't find the field '|1' referred to in your expression." i see no field reference in the code, i'm sorry i am not very knowledgeable when it comes to this type of coding.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    what line is it stopping at?

    Is data a query or a table?

    what is the exact code you are using now? copy and paste it

  7. #7
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11
    please see images to answer your question.
    "data" is a table
    Click image for larger version. 

Name:	1.JPG 
Views:	12 
Size:	18.0 KB 
ID:	26585Click image for larger version. 

Name:	2.JPG 
Views:	12 
Size:	36.4 KB 
ID:	26586

    Code:
    Option Compare Database
    
    
    Function waitFor(NumberOfSeconds As Variant)
    Dim start As Variant
        
        start = Timer
        Do While Timer < start + NumberOfSeconds
            DoEvents
        Loop
     
    End Function
    
    
    Private Sub Command0_Click()
    Dim rst As dao.Recordset
    
    
    Set rst = CurrentDb.openrecordset("SELECT * From data", dbOpenSnapshot)
    While Not rst.EOF
        Application.FollowHyperlink Address:="https://www.dell.com/support/Assets-Online/us/en/blahblah/#/product-list?servicetag=" & [service tag#]
        waitFor 3
        rst.MoveNext
    Wend
    
    
    End Sub

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    three things strike me about this line

    :="https://www.dell.com/support/Assets-Online/us/en/blahblah/#/product-list?servicetag=" & [service tag#]

    is blahblah correct?

    is the whole hyperlink correct? - suggest use debug.print to display the calculated string in the immediate window and compare with one you know works - perhaps [service tag#] needs to be surround with quotes?


    and access is looking for a something called 'Service tag#'

    1. using # in field and control names creates all sorts of issues - this may be one of them
    2. where is 'Service tag#'?
    if it is part of the data recordset you should use rst.fields([Service tag#]") - the # messes things up so syntax may be slightly different
    if it is a control on your form it should be me.[service tag#] - again, the # messes things up so syntax may be slightly different

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    one other thing - if you need to be logged into your dell account, I would expect (but I may be wrong) either your hyperlink to include login details, or there is something else you need to do to login - you would need to talk to dell.

  10. #10
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11
    no, Blahblah is in place of what i assume is my customer number, i am replacing it each time with the actual number(simple numbers and letters, no special characters)

    "service Tag# is the name of the field in the table "data" that i am trying to include in each generated string. i got this string from a known working button that i would have to click through a few hundred times which is why i am trying to automate it (for now and the future)


    i was trying to avoid rewriting all of the field references all over the database, but if its neccissary i can rename the field.


    where would the reference rst.fields([Service tag#]") be used? at the end of the url string? if so, i just tried that and it didnt want to work (cant compile with the ' " ' and gives the same error as before without it)

    as far as login goes, my plan was to manually login before running the batch, i know the string works from a form on an individual basis.


    thanks again

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I missed a quote

    should be

    rst.fields("[Service tag#]")

    if you didn't have spaces and non alphanumeric characters, it would just be rst!Servicetag

    where would the reference rst.fields([Service tag#]") be used? at the end of the url string?
    yes - duly corrected

  12. #12
    Feddy is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Location
    Space Coast Florida
    Posts
    11
    ok, that got it!

    works great, i increased the delay to 6 seconds.

    Final Code:

    Code:
    Option Compare Database
    
    Function waitFor(NumberOfSeconds As Variant)
    Dim start As Variant
        
        start = Timer
        Do While Timer < start + NumberOfSeconds
            DoEvents
        Loop
     
    End Function
    
    
    Private Sub Command0_Click()
    Dim rst As dao.Recordset
    
    
    Set rst = CurrentDb.openrecordset("SELECT * From data", dbOpenSnapshot)
    While Not rst.EOF
        Application.FollowHyperlink Address:="https://www.dell.com/support/Assets-Online/us/en/mycodehere/#/product-list?servicetag=" & rst.Fields("[Service tag#]")
        waitFor 6
        rst.MoveNext
    Wend
    
    
    End Sub

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    glad you got it working

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

Similar Threads

  1. mdb to online
    By ashu.doc in forum Access
    Replies: 5
    Last Post: 07-22-2015, 04:47 PM
  2. Automating Access with Gmail
    By mdub in forum Programming
    Replies: 5
    Last Post: 12-07-2011, 07:32 PM
  3. Mass enrollment form
    By Ted C in forum Forms
    Replies: 1
    Last Post: 07-26-2010, 01:45 PM
  4. Automating Reports
    By Christopher in forum Import/Export Data
    Replies: 3
    Last Post: 04-22-2010, 01:40 PM
  5. School Enrollment Database
    By jpepin in forum Database Design
    Replies: 1
    Last Post: 04-08-2010, 05:23 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