Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-26-2004, 10:06 AM   #1 (permalink)
patelk
Registered User
 
Join Date: Oct 2004
Posts: 3
patelk is on a distinguished road
Question Creating Labels in VB

the following is what i am trying to do:

Read 1st record
Save the 1st record (box#) in a variable
Print box#
Print Gf#
Read Next
If box# saved? if yes then go back to print gf. if no then move to next record and go back to the save the 2nd record (box#) in a variable

this is what i have so far:

Dim labelApp As Word.Application
Dim labelDoc As Word.Document
Dim skip As Boolean
Dim madenew As Boolean
Dim newone As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim boxno as String

'Start a new document in Word
Set labelApp = CreateObject("Word.application")
Set labelDoc = labelApp.Documents.Add

madnew = False
If labelApp.Documents.Count = 0 Then
labelApp.Documents.Add
madenew = True
newone = labelDoc.Name
End If

labelApp.MailingLabel.DefaultPrintBarCode = False
labelApp.MailingLabel.CreateNewDocument Name:="5163", Address:="", _
Autotext:="toolscreatelabels1", lasertray:=wdPrinterManualFeed, _
extractaddress:=False, printEpostagelabel:=False, Vertical:=False
skip = True

conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ETC;Data Source=PHNOTES01"
boxno = InputBox("Type the box# you want labels for.")
rs.Open "SELECT * FROM ETCLog WHERE box# = " & boxno, conn, adOpenDynamic, adLockOptimistic

If Not rs.EOF Then
rs.MoveFirst
boxno = boxno
Selection.Font.Underline = wdUnderlineSingle
Selection.Font.Bold = True
Selection.Font.Name = "Arial Bold"
Selection.Font.Size = 14
Selection.TypeText Text:="Box#: " & rs!box#
Selection.TypeParagraph

If rs!box# = boxno Then
Selection.TypeText Text:=rs!gf#
Else
rs.MoveNext
Selection.MoveRight unit:=wdCell
If skip Then
Selection.MoveRight unit:=wdCell
skip = False
Else
skip = True
End If

End If
End If

i get an error at the highlighted above saying: object variable or with block variable not set and i put the with and end with in but then i get and error at rs!box# saying method or data member not found. not sure what i am doing wrong

am i missing something or doing this all wrong?
patelk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ combine with VB? john_tran MS Technologies ( ASP, VB, C#, .NET ) 4 10-21-2004 05:40 AM
VB or C#, or something else Apodysophilia MS Technologies ( ASP, VB, C#, .NET ) 6 10-15-2004 09:48 AM
creating dynamic variable names sde PHP 5 11-02-2002 09:03 AM
phpbuilder.com uses vb now.. wow sde PHP 1 08-13-2002 11:28 AM


All times are GMT -8. The time now is 06:40 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting