D
Duane Hookom
My suggestion wasn't to send the report name. It was to send the report
object. If you want to send the report name then you would need code in your
function like:
Dim rpt As Report
Set rpt = Reports(strReportName)
--
Duane Hookom
MS Access MVP
object. If you want to send the report name then you would need code in your
function like:
Dim rpt As Report
Set rpt = Reports(strReportName)
--
Duane Hookom
MS Access MVP
Alp said:After adding the report name (whichReport As Report) I am getting errors.
At
least while calling the function from the report. I have tried various
ways
(as far as my wit goes) but couldn't find the correct one.
Using: Call BoxIt(2270, 75, 285, 338, 28, FullName, (r_BE1_v2)) returns
Run-time error 424 Object required
Call BoxIt(2270, 75, 285, 338, 28, FullName, r_BE1_v2) returns a compile
error ByRef argument type mismatch
Call BoxIt(2270, 75, 285, 338, 28, FullName, "r_BE1_v2") returns a compile
Type mismatch
Call BoxIt(2270, 75, 285, 338, 28, FullName, ((r_BE1_v2))) returns
Run-time
error 424 Object required
I played around with the function itself as well, still at same
position...
It seems I just can't pass the report name properly to the function. I can
say I "know" it must be possible.
Alp
Duane Hookom said:Nice work.
You could send the current report to the function IE:
Public Function BoxIt(BoxLeft As Long, BoxTop As Long, _
BoxWidth As Long, BoxHeight As Long, BoxNum As Long, _
whichField As String, whichReport as Report)
Then replace all "Me." with "whichReport."
--
Duane Hookom
MS Access MVP
Alp said:Hi Duane,
Without your consent (sorry about that, just forgot) I have converted your
suggestion into a function to be placed under the OnFormat event of detail
section as:
'Source provided by Duane Hookom at microsoft.public.access.reports NG on
22/01/2005
'Modified into a function by Alp Bekisoglu on 22/01/2005
Public Function BoxIt(BoxLeft As Long, BoxTop As Long, BoxWidth As
Long,
BoxHeight As Long, BoxNum As Long, whichField As String)
Dim lngLeft As Long ' = 2270 '720 '1/2 inch
Dim lngTop As Long ' = 75 '360 '1/4 inch
Dim lngWidth As Long ' = 285 'width of each box
Dim lngHeight As Long ' = 338 'height of each box
Dim lngBoxCount As Long ' = 28 'number of boxes
Dim strField As String
lngLeft = BoxLeft
lngTop = BoxTop
lngWidth = BoxWidth
lngHeight = BoxHeight
lngBoxCount = BoxNum
strField = whichField
Dim lngI As Long 'for looping
Me.FontSize = 10
Me.FontName = "Arial"
For lngI = 1 To lngBoxCount
Me.Line (lngLeft + (lngI - 1) * lngWidth, lngTop)- _
Step(lngWidth, lngHeight), , B
Me.CurrentX = lngLeft + (lngI - 1) * lngWidth
Me.CurrentY = lngTop + 20
Me.Print Mid(strField & Space(lngBoxCount), lngI, 1)
Next
End Function
It seems to work when called as: Call BoxIt(2270, 75, 285, 338, 28,
Me.FullName) under the OnFormat event. The further question is: how can I
get rid of having to enter "Me." so the function could be of better use
both
for me as well as whoever might need it? I also thought of setting the
font
name and size in the call, maybe I will include that as well.
Alp
Here is a more interesting method that doesn't use multiple text
boxes.
The
code uses the Me.Print and Me.Line methods to do all the work.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Const lngLeft As Long = 720 '1/2 inch
Const lngTop As Long = 360 '1/4 inch
Const lngWidth As Long = 250 'width of each box
Const lngHeight As Long = 400 'height of each box
Const lngBoxCount As Long = 20 'number of boxes
Dim lngI As Long 'for looping
Dim strLastName As String 'store name
strLastName = Me.txtLastName
Me.FontSize = 20
Me.FontName = "Courier New"
For lngI = 1 To lngBoxCount
Me.Line (lngLeft + (lngI - 1) * lngWidth, lngTop)- _
Step(lngWidth, lngHeight), , B
Me.CurrentX = lngLeft + (lngI - 1) * lngWidth
Me.CurrentY = lngTop + 20
Me.Print Mid(strLastName & Space(lngBoxCount), lngI, 1)
Next
End Sub
--
Duane Hookom
MS Access MVP
Hi John and Fred,
Thanks for the advices. Looks like using the Mid is the only way out as
I
also thought (and using actually).
John I had that function, a very similar one, in mind as well but
wanted
to
find out if there could be different approach(es).
Thanks again guys.
Alp
With some creative naming you could use vba code to populate the "box"
controls.
Then you could use a sub routine something like the following
UNTESTED
code.
Put a control on the report to hold the whole string and set its
visible
property to false. Then name all the box controls with the same name
plus
a
1-up number. Then call the UNTESTED code below for each control that
has
to be
parsed out - Populate "FieldName"
Sub PopulateBoxes(strControlName As String)
Dim iLong As Integer
Dim strParse As String
strParse = Me(strControlName) & vbNullString
For iLong = 1 To Len(strParse)
Me(strControlName & iLong) = Mid(strParse, iLong, 1)
Next iLong
End Sub
fredg wrote:
On Sat, 22 Jan 2005 04:56:55 +0800, Alp wrote:
Hi Experts,
In need to design a report where each character of the report data
(almos
all of them) needs to be displayed in a seperate box. The
number
of
boxes
are pre-set for each report item thus parsing stops when data
string
length
is reached and might leave some boxes empty. Same as filling up a
pre-printed form.
What would be the proper approach? Something better than
Me.boxname
=
Mid(string, ?, 1) for each box's source.
Thanks in advance.
Alp
To parse each character of a Field (or any string) into it's own
control:
=Mid([FieldName],1,1)
=Mid([FieldName],2,1)
=Mid([FieldName],3,1)
etc.
in the appropriate unbound control.