Oops Should be in stock (Not Stack)
Oops Should be in stock (Not Stack)
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.
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
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:
with the line below and try again:Code:Me.Quantity = doc.getElementsByName("Quantity")(0).Value
Cheers,Code:Me.Quantity = doc.Forms("AddBasketForm").elements("Quantity").Value
John
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
Use error handling to manage error 91
AND/OR, wrap your expression in the Nz function
BTW you don't need the .Value as its the default propertyCode:Me.Quantity = Nz(doc.getElementsByName("Quantity")(0).Value,0)
Thanks Colin I'll try that
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