PC Review


Reply
Thread Tools Rate Thread

Code trouble please help

 
 
carlee
Guest
Posts: n/a
 
      3rd Sep 2003
Hi there,

I am really stuck and need help.

I have the following code which is being used to send
information directly to the com1 port on a printer via
a .prn file. Everything seems to work well, except when i
try to dump what is in the table "tblLabel" in to the
variable data_item1.

There are three fields in tblLabel: ShipmenNumber,
VarietyNumber, PropagationNumber. ShipmentNumber is a
number datatype, VarietyNumber is a number datatype, and
PropagatinNumber is a text datatype. I keep getting a
datatype mismatch and am not sure how to prevent this.

Can you help? Many thanks.



Private Sub labels()

'program for printing single feed continuous labels
Close #1

Open "P:\Label.prn" For Output As #1

Dim ctrl_stx As String
Dim ctrl_etx As String
Dim ctrl_esc As String
Dim ctrl_cr As String
Dim ctrl_etb As String
Dim ctrl_can As String
Dim ctrl_si As String
Dim c39_tab As String

Dim prt_set_mem As String
Dim prt_run_on As String
Dim ptr_end_of_print As String
Dim ptr_media_sens As String
Dim ptr_lbl_retract_dist As String
Dim ptr_img_bnd As String
Dim ptr_dis_self_strip As String
Dim ptr_sel_lbl_fmt As String
Dim ptr_clr_lbl_dat As String


Dim data_item1 As String

ctrl_stx = Chr(2) ' start command sequence
ctrl_etx = Chr(3) ' end command sequence
ctrl_esc = Chr(27) 'escape code

ctrl_cr = Chr(13) 'data separator
ctrl_etb = Chr(23) 'print command
ctrl_can = Chr(24) 'clear print buffer
ctrl_si = Chr(15) 'configuration prefix
c39_tab = Chr(9) 'code 39 tab function


'printer initialization commands

prt_set_mem = ctrl_stx & ctrl_si & "N128" & ctrl_etx '
set printer memory to 128K
prt_run_on = ctrl_stx & ctrl_si & "L1850" &
ctrl_etx 'set label run on length
ptr_end_of_print = ctrl_stx & ctrl_si & "D169" &
ctrl_etx 'set end of print skip distance
ptr_media_sens = ctrl_stx & ctrl_si & "g1,575" &
ctrl_etx ' set media senstivity
ptr_img_bnd = ctrl_stx & ctrl_si & "I1" &
ctrl_etx 'set image number of image bands
ptr_dis_self_strip = ctrl_stx & ctrl_si & "t0" &
ctrl_etx ' disable self strip mode
ptr_lbl_retract_dist = ctrl_stx & ctrl_si & "r0" &
ctrl_etx 'set label retract distrance
ptr_sel_lbl_fmt = ctrl_stx & ctrl_esc & "E0" &
ctrl_etx 'select label format ( #0)
ptr_clr_lbl_dat = ptr_clr_lbl_dat & ctrl_can &
ctrl_etx ' clear label data

'send initialization string to output file
Print #1, prt_set_mem
Print #1, prt_run_on
Print #1, ptr_end_of_print
Print #1, ptr_media_sens
Print #1, ptr_img_bnd
Print #1, ptr_dis_self_strip
Print #1, ptr_lbl_retract_dist
Print #1, ptr_sel_lbl_fmt
Print #1, ptr_clr_lbl_dat


'open tblLabel
DoCmd.OpenTable "tblLabel"
'go to first record
DoCmd.GoToRecord , , acFirst

data_item1 = LTrim(Format(!ShipmentNumber)) & c39_tab &
LTrim(Format(!VarietyNumber)) & c39_tab & RTrim(!
PropagationNumber)
Print #1, data_item1
Close #1

 
Reply With Quote
 
 
 
Reply

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Another trouble when I migrate vb code to c# code David Anton Microsoft C# .NET 0 1st May 2009 02:43 PM
Trouble with a VBA code nikwak Microsoft Excel Programming 0 6th Aug 2008 04:29 PM
Macro code to dll and vba code trouble shoot. mario Microsoft Excel Programming 0 15th May 2008 07:07 PM
Trouble with this code =?Utf-8?B?Sk9VSU9VSQ==?= Microsoft Excel Programming 4 11th Jun 2006 04:49 PM
Still having trouble with code Richard Microsoft Excel Misc 1 25th Aug 2004 12:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:27 AM.