Populate a text box on a report by code - help please.

F

FatMan

Hi all:
I would like to know if it is possible to populate an unbound text box on a
report using code.

I have a report that includes a barcode and my users have now decided that
they would like to add a unique number to the end of the barcode when it
prints. In my program I have a loop with a counter that prints the required
number of barcodes. What I really would like to do is concatenate my barcode
and counter and have this populate the unbound text box on my report. Can
this be done?

Any help is greatly appreciated.

Thanks,
FatMan
 
M

Marshall Barton

FatMan said:
I would like to know if it is possible to populate an unbound text box on a
report using code.

I have a report that includes a barcode and my users have now decided that
they would like to add a unique number to the end of the barcode when it
prints. In my program I have a loop with a counter that prints the required
number of barcodes. What I really would like to do is concatenate my barcode
and counter and have this populate the unbound text box on my report. Can
this be done?


Put the code in the text box's section's Format event. The
code to set the text box's value might be something like:

Me.[the text box] = barcode & counter
 
F

FatMan

Marshall:
Thanks for the reply.

I have tried what you have suggested, but had to place the code in the
"Format" option on the Format tab as there is no Format on the event tab.
The event tab is blank for this unbound text box on my report.

I type in.......

Me.[txt90] =[BarCode] & [ intCounter] & "*"

and access display/converts it to.......

m"e.[txt90] = =[Bar"c\od"e] & [ i"n\tc"ou"n"ter] & *"

When I tried placing....=[BarCode] & [ intCounter] & "*" .... as the
control source the reports displays a box like a parameter query asking for a
value.

To print the report the user clicks on a command button on a form. The code
behind the command button is listed below.

Is there any why to concatenate...intCounter & "*"...with my barcode?

Any help is greatly appreciated.

Thanks,
FatMan


Code...............

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Dim stDocName As String
Dim intCounter, intNumOfLab As Integer

'number of labels to print
intNumOfLab =
Forms.frmIntakeDataEntry.ctrlIntakeDataEntrySubformTotalBinsSum

'name of report
stDocName = "rptIntakeSlip-5x8-RotatedBarCode"

'check to see if number of labels to print is greater than zero
If Nz(intNumOfLab) > 0 Then

'Check Print Options (1 = Tag for every bin, 2 = one tag only)
If framePrintOptions = 1 Then

'Print the number of labels required plus one extra
Do While intCounter < intNumOfLab + 1

DoCmd.OpenReport stDocName, acPreview
intCounter = intCounter + 1
Loop
Else
DoCmd.OpenReport stDocName, acPreview
End If
Else
'if the physical bins is not great than zero or is null then display
message
MsgBox "Please check the PHYSICAL BINS entered as there appears to
be no bin info entered.", vbCritical + vbOKOnly, "ERROR - Physical Bins"


End If


Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub




Marshall Barton said:
FatMan said:
I would like to know if it is possible to populate an unbound text box on a
report using code.

I have a report that includes a barcode and my users have now decided that
they would like to add a unique number to the end of the barcode when it
prints. In my program I have a loop with a counter that prints the required
number of barcodes. What I really would like to do is concatenate my barcode
and counter and have this populate the unbound text box on my report. Can
this be done?


Put the code in the text box's section's Format event. The
code to set the text box's value might be something like:

Me.[the text box] = barcode & counter
 
M

Marshall Barton

You really went off the rails there. You were supposed to
put the code in the Format event PROCEDURE of the SECTION
that contains the text box.

I don't see what the form code has to do with the question.
--
Marsh
MVP [MS Access]

I have tried what you have suggested, but had to place the code in the
"Format" option on the Format tab as there is no Format on the event tab.
The event tab is blank for this unbound text box on my report.

I type in.......

Me.[txt90] =[BarCode] & [ intCounter] & "*"

and access display/converts it to.......

m"e.[txt90] = =[Bar"c\od"e] & [ i"n\tc"ou"n"ter] & *"

When I tried placing....=[BarCode] & [ intCounter] & "*" .... as the
control source the reports displays a box like a parameter query asking for a
value.

To print the report the user clicks on a command button on a form. The code
behind the command button is listed below.

Is there any why to concatenate...intCounter & "*"...with my barcode?


Code...............

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Dim stDocName As String
Dim intCounter, intNumOfLab As Integer

'number of labels to print
intNumOfLab =
Forms.frmIntakeDataEntry.ctrlIntakeDataEntrySubformTotalBinsSum

'name of report
stDocName = "rptIntakeSlip-5x8-RotatedBarCode"

'check to see if number of labels to print is greater than zero
If Nz(intNumOfLab) > 0 Then

'Check Print Options (1 = Tag for every bin, 2 = one tag only)
If framePrintOptions = 1 Then

'Print the number of labels required plus one extra
Do While intCounter < intNumOfLab + 1

DoCmd.OpenReport stDocName, acPreview
intCounter = intCounter + 1
Loop
Else
DoCmd.OpenReport stDocName, acPreview
End If
Else
'if the physical bins is not great than zero or is null then display
message
MsgBox "Please check the PHYSICAL BINS entered as there appears to
be no bin info entered.", vbCritical + vbOKOnly, "ERROR - Physical Bins"

End If

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub


Marshall Barton said:
FatMan said:
I would like to know if it is possible to populate an unbound text box on a
report using code.

I have a report that includes a barcode and my users have now decided that
they would like to add a unique number to the end of the barcode when it
prints. In my program I have a loop with a counter that prints the required
number of barcodes. What I really would like to do is concatenate my barcode
and counter and have this populate the unbound text box on my report. Can
this be done?


Put the code in the text box's section's Format event. The
code to set the text box's value might be something like:

Me.[the text box] = barcode & counter
 

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