Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 20th, 2006, 04:31 PM
teeheiman's Avatar
teeheiman teeheiman is offline
Let the Wookie Win
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: United States, Califonia
Posts: 190 teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 20 h 14 m 39 sec
Reputation Power: 16
VBS Create Packing Slip Error

Ive created this script to create packing slips per order and list the items sold, but for some reasons items that are not matched up to the order are being added. Not sure why Ill post my code and explain:

I cant see whats wrong with it but maybe in the loop somewhere?

Open that dabase and start to loop through the orders
Code:
'----------------------- Create packing Slips ---------------------------
strsheetcount = 1
xlrow = 1
master_file = "C:\Inetpub\WebSites\website\vbs\pslip-template.xls"
save_as_file = "C:\Inetpub\Batch\NB\" & strdate & "-pslip.xls"

Set xl = CreateObject("Excel.Application")
xl.Visible = False
xl.DisplayAlerts = False
xl.Interactive = False

Set wrk = xl.Workbooks.Open(master_file)
'Set wrkSht = wrk.sheets(1)		

		'Set to Sheet1 because that is excel default
	strsql = "Select * from tb_orders where status='Step 1'"
		rsitems.open strsql, adocon
	Do While Not Rsitems.EOF
	strsql = "UPDATE tb_orders SET Status = 'Step 2'WHERE order_ID ='" & rsitems("order_ID") & "'"
	adocon.execute strsql
		Set wrkSht = wrk.sheets(strsheetcount)
		stritemcount = 0


Write Out the order Number Ship/Ect. This works fine
Code:
        	wrkSht.Cells(7, 1).Value = "#" & rsitems("order_ID")
		wrkSht.Cells(8, 1).Value = "Date:"
		wrkSht.Cells(9, 1).Value = "Ship to:"
		wrkSht.Cells(13, 1).Value = "Via:"
		wrkSht.Cells(15, 1).Value = "Item"
		wrkSht.Cells(15, 8).Value = "Code"
		wrkSht.Cells(15, 10).Value = "Qty"

		wrkSht.Cells(7, 3).Value = "Packing Slip " & rsitems("order_ID") & " for websitecom"
		wrkSht.Cells(8, 3).Value = now
		wrkSht.Cells(9, 3).Value = rsitems("s_firstname") & " " & rsitems("s_lastname")
		wrkSht.Cells(10, 3).Value = rsitems("s_address")
		wrkSht.Cells(11, 3).Value = rsitems("s_city") & " " & rsitems("s_state") & ", " & rsitems("s_zip")
		wrkSht.Cells(13, 3).Value = strshipping_method


This is where im running into the problem, it selects the order number then opens the sold table and selects everything from that order, but its selecting extra items to.
Code:
	strsql2 = "Select * from tb_sold where order_id='" & rsitems("order_ID") & "'"
	rsitems2.open strsql2, adocon
	Do While Not Rsitems2.EOF
		
		wrkSht.Cells(16 + cint(stritemcount), 1).Value = rsitems2("Item_Name")
		wrkSht.Cells(17 + cint(stritemcount), 1).Value = "http://www.website.com/item.asp?itemnum=" & rsitems2("Item_ID")
		wrkSht.Cells(16 + cint(stritemcount), 8).Value = rsitems2("Item_ID")
		wrkSht.Cells(16 + cint(stritemcount), 10).Value = rsitems2("qty")
		stritemcount = stritemcount + 2
		
	rsitems2.movenext
	loop


		xlrow = xlrow + 1

	rsitems2.close
	rsitems.movenext
	If NOT rsItems.EOF then		'IF THERE IS ANOTHER RECORD, COPY/PASTE


This checks to see if theres another order and adds another sheet because excels default is 3 pages, if anymore orders then 3, i gotta add another page

Code:
	'----------------------------------------------------------------------------------------
		'	PASTE NEW SHEET
		'-----------------------------------------------------------------------------------------
		strsheetcount = strsheetcount + 1

		If strsheetcount > 3 Then
			'wrk.sheets.add()
			wrk.sheets.add ,wrk.sheets(wrk.sheets.count)
		end if
	'Set sh = wrk.Sheets.Add(, wrk.Sheets(wrk.Sheets.Count))	  
	  'With sh.Range("A1").Borders(xlEdgeBottom)
   	     '.LineStyle = xlContinuous
   	     '.Weight = xlThin
   	     '.ColorIndex = xlAutomatic
 	  'End With 

		'Set wrkSht = wrk.sheets("Sheet1")		'SELECT THE ORIGINAL
		wrk.sheets("Sheet1").Select
		wrkSht.Cells.Copy				'COPY CELLS FROM 1st

		Set wrkSht = wrk.sheets("Sheet" & strsheetcount)		'Set 2nd wrkSht object to sheet2
		'wrkSht.Cells.Select

		wrkSht.Paste			'Paste the copied text
		xl.CutCopyMode = False		'I have no idea what this means

	End If
loop

rsitems.close
adocon.close
set rsitems = nothing
set rsitems2 = nothing
set adocon = nothing


Code:
'----------------------------------
'	SAVE MASTER FILE & QUIT
'----------------------------------
wrk.SaveAs save_as_file			'THIS SECTION CAN BE USED TO SET FILE TYPE


Save The Excel File

Save & Quit
[code]
'----------------------------------------------------------------------------
'	DIFFERENT FILE TYPES
'------------------------------------------------------------------------------
'wrk.SaveAs ave_as_file, -4158			'Save as TAB DELIMITED File	
'wrk.SaveAs ave_as_file, 6			'Save as a CSV File


wrk.Close
Set wrkSht = Nothing
Set wrk = Nothing

xl.Quit
Set xl = Nothing


Hope ya can help,

Thank you,
Billy
__________________
That's 'cause droids don't pull people's arms out of their sockets when they lose. Wookies are known to do that.

Reply With Quote
  #2  
Old September 22nd, 2006, 03:19 AM
teeheiman's Avatar
teeheiman teeheiman is offline
Let the Wookie Win
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: United States, Califonia
Posts: 190 teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 20 h 14 m 39 sec
Reputation Power: 16
Do I need to explain better? This is very important.

Thanks

Reply With Quote
  #3  
Old September 22nd, 2006, 03:23 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Step through your code with the debugger, you should then be able to figure out what is going wrong.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #4  
Old September 22nd, 2006, 05:06 PM
teeheiman's Avatar
teeheiman teeheiman is offline
Let the Wookie Win
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: United States, Califonia
Posts: 190 teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level)teeheiman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 20 h 14 m 39 sec
Reputation Power: 16
Theres no bugs in it, no errors, it just doesnt work right

Reply With Quote
  #5  
Old September 22nd, 2006, 10:14 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Quote:
Originally Posted by teeheiman
Theres no bugs in it, no errors, it just doesnt work right

Interesting how code with no bugs and no errors doesn't work right.

If you want someone to re-work your entire code then try the "hire a programmer" forum.

If you want to work out the problem yourself, then I'll go back to "step through your code with the debugger", inspect variables at each stop, figure out what isn't working right. The VB debugger is a very good tool, at least in the VB implementations I use.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > VBS Create Packing Slip Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT