Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    jeffreylewis is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    19
    Oops Should be in stock (Not Stack)

  2. #17
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Quote Originally Posted by jeffreylewis View Post
    Hi

    That almost works exept it doesn't differentiate between in stack and out of stock

    Many thanks for staying with me

    Regards
    Jeff
    Hi Jeff!

    The function returns True if the element "Quantity" exists in page's body and have a value greater than zero and False in any other condition, and, in addition, sets the form's controls "Quantity" and "ShowPrice".

    You can use the returned value to set a checkbox "In stock" (as in my example), to show/hide a label with a message about the availability or to show a relevant messagebox etc.

    Please let me know If I didn't understand well.

  3. #18
    jeffreylewis is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    19
    Hi Thanks for your continued advice.


    There does not seem to be any difference to the web page in either mode; "Available" or "Not Available" they both have this line in exactly the same way.
    <input name="Quantity" type="hidden" value="1">
    machinemart.co.uk/p/051012200/


    What I have noticed is though, is that the difference between "Available" or "Not Available" is that the label "Qty" appears on the "Available" record and does not appear on the "Not Available" one
    machinemart.co.uk/p/clarke-bip1000-1-electric-water-pump/


    So the thing that remains to be seen is getting the code to recognizing the element "Qty"
    When I look at it with the Browser Inspector the name given to it is "#Text"
    I have tried "div.quantity.#Text" too


    So Thats where I am now.


    best regards
    Jeff
    Attached Thumbnails Attached Thumbnails Available.jpg  

  4. #19
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Hi Jeff!

    Now it's clear to me!

    Notice that there are many <input> elements with name="Quantity" in the web pages but only one (or none) for the form with id="AddBasketForm" which is the form of the selected product.

    You will find that in the web page machinemart.co.uk/p/051012200/ there are no any <input name="Quantity"...> under the node <form id="AddBasketForm" ...>

    So, in the code of the ItemInStock() function, replace the line:
    Code:
    Me.Quantity = doc.getElementsByName("Quantity")(0).Value
    with the line below and try again:
    Code:
    Me.Quantity = doc.Forms("AddBasketForm").elements("Quantity").Value
    Cheers,
    John

  5. #20
    jeffreylewis is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    19
    Hi again John

    This works OK for the records on the MachineMart site that are In stock
    Me.chkInStock = (doc.Forms("AddBasketForm").elements("Quantity").V alue)
    But the code gives error 91 on records that are not in stock. (Object Variable or with Block variable not Set)

    Many Thanks
    Jeff

  6. #21
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Use error handling to manage error 91
    AND/OR, wrap your expression in the Nz function
    Code:
      Me.Quantity = Nz(doc.getElementsByName("Quantity")(0).Value,0)
    BTW you don't need the .Value as its the default property
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #22
    jeffreylewis is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    19
    Thanks Colin I'll try that

  8. #23
    jeffreylewis is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    19
    Hi Guys


    Thanks very much to every one who helped me. Especially Accesstos, Gicu, Isladogs
    I have learned a lot about Ms Access and VBA


    I wish I'd found this website before.


    Once again
    Thanks Guys

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

Similar Threads

  1. Replies: 2
    Last Post: 02-03-2014, 02:53 PM
  2. Web Browser Control
    By MFS in forum Programming
    Replies: 0
    Last Post: 02-28-2013, 11:08 AM
  3. Web Browser Control
    By imran688 in forum Programming
    Replies: 1
    Last Post: 11-29-2012, 03:52 PM
  4. Focus in web browser control
    By bjornhe in forum Access
    Replies: 0
    Last Post: 10-27-2011, 05:10 AM
  5. Web Browser Control
    By ctgann in forum Forms
    Replies: 5
    Last Post: 03-18-2011, 08:17 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