Code trouble please help

C

carlee

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top