Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object required error

Status
Not open for further replies.

gargs

Technical User
Apr 3, 2001
14
NZ
I am writing a clientside ordering form as part of an assignment. The user enters their details into text boxes and selects the products and quantities they wish to order. When they click the cmdinvoice button a new window opens and all the order information is suppose to be written to the new document.

The code below does open the new window but I also get an "object required 'nw'" error message and nothing is printed on the page.

sub cmdinvoice_onclick()
dim nw
nw = window.open ("","")
nw.document.open()
nw.document.write ("INVOICE")
nw.document.close

Has anyone got an suggestions? I'm pretty new to programming so please forgive me if I've got it completely wrong.

Thanks
 
Do you HAVE to use vbscript to open the window??

I could tell you how to do this in javascript, if that would help -- or research a bit if it HAS to be in vbscript...

Just as a note, you say you're new to programming -- you know that client side vbscript won't work in NS, right?

let me know
Paul Prewett
 
Hi paul

The institute that I'm doing my degree at is a Microsoft shop so they only want to teach MS products. We are able to use javascript if we want but will have little or no support from the lecturers. Yes I am aware that vbscript won't work in NS and I have also noticed there are many more resources available for javascript.

Anyway to answer your question, I could use javascript to open the window as long as I can call variables that have been defined in other vbscripts. I have about 350 lines of code at the moment and I'd rather not have to rewrite them in javascript.

Thanks for your response

Grattan Le Cheminant
 
**Phwew**

Ok, I was about to give up --

The problem is that you have not declared 'nw' to be an object -- hence the 'object expected' error message you recieved.

In order to set it to be an object, you have to use the 'set' keyword. This tells the script engine that you are taking 'nw' from variable status to object status, and then you can use the window object's methods and properties...

Here's what I did to get it there:
Code:
sub cmdinvoice_onclick()
	dim nw
	set nw = window.open()
	nw.document.write("INVOICE")
	nw.close
end sub
good luck!
Paul Prewett

ps -- tell your professors that if they must make you learn vbscript, make it server side (ASP), and if they just have to stay Microsoft on client side, then use JScript (make it much easier when you get out to develop with javascript) ;-)
No offense, of course... just wierd to see an educational Microsoft shop. I didn't think they existed... my University is so anti-Microsoft, it sometimes gets on my nerves. Anywho -- good luck and all, and come back anytime. :)
 
Thanks Paul, it works now.

Our next assignment is to develop an ASP site with an Access database. Should be interesting.

Grattan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top