Need To Refer To Field In Report (1 Viewer)

ANDREW_SAUNDERS

Registered User.
Local time
Today, 04:59
Joined
Mar 11, 2002
Messages
12
I am making a label printing database
every thing is working ok but I need to referance a specific field which contains the quantity to print

i can get it to work by using in the code
qytprint= 3 ( or what ever number hard coded)

but i need to pick up the corect variable amount from
table = goodsrec field = qty

I thought that by using ;-
qytprint= me![goodsrec].qty

it might work !!

brain has gone on go slow !!

regards
Andrew
 

ListO

Señor Member
Local time
Today, 04:59
Joined
Feb 2, 2000
Messages
162
Where is the field which holds the quantity to be printed? Is it in a table, query, textbox on a form, or where?

If on a form, you'd use:
qytprint = forms![formname].[textboxname]
substituting the formname with the name of your form, and textboxname with the name of the textbox.

Is this what you mean?
 

ANDREW_SAUNDERS

Registered User.
Local time
Today, 04:59
Joined
Mar 11, 2002
Messages
12
Hi
thanks for replying

what I have is some vb code which has been adapted from a function i have downloaded this enables printing of labels on sheet format I have removed the parts that i am not using ie skip blank used labels etc

by entering in the code a fixed quanity number it works with my application as required

but I realy need to pick up the number of individual labels required from an existing report which has a field called QTY

the code I am using is :-

'Prompt user for number of copies
vResp = InputBox("How many copies of each label?", "Label Saver", 1)
If vResp = "" Then
'Cancel was clicked
Cancel = True
GoTo ls_ReportOnOpen_exit
End If
iCopies = CInt(vResp) ' I HAVE SET THIS TO FIXED NUMBER


so I need to allow iCopies to pick up data from the printed field QTY

I hope I have been a bit clearer now
regards
Andrew
 

Fizzio

Chief Torturer
Local time
Today, 04:59
Joined
Feb 21, 2002
Messages
1,885
ListO has already underlined the principle but I'm not sure if you can grab a value from a report to use in another report but try this. You need to initially open the report with the quantity value on, grab the value then close the report ie

Docmd.openreport "NameOfReport", acViewPreview
iCopies = reports![NameOfReport]![Qty]
docmd.Close acReport, "NameOfReport"

does this help (and work for that matter?)
;)
 

ANDREW_SAUNDERS

Registered User.
Local time
Today, 04:59
Joined
Mar 11, 2002
Messages
12
well I have tried what you sugested
and unfortunatly it did not work as did other ideas it prompted !

To make things easier for me to grasp the principals i have made a demo table with ony 4 records in it

have called table "Table1 " the field with required number of lables to be printed is "ReceiptQty" set to 1 2 3 4 etc

using the code i have previously posted how do I go about picking up the individual number of lables for each record set ?
ie 1 for the first label 2 for second etc


now confused !!
apreciate any guidence
Andrew
 

ANDREW_SAUNDERS

Registered User.
Local time
Today, 04:59
Joined
Mar 11, 2002
Messages
12
oh

It would be useful for you to know where it was falling over

when i run the report it cannot find the field "receivedqty"
 

simongallop

Registered User.
Local time
Today, 04:59
Joined
Oct 17, 2000
Messages
611
To pick up data from a record:

Dim MyRS as Recordset
Set MyRS = Currentdb.OpenRecordset("NameOfTable",dbopendynaset)

'First Record
MyRS.MoveFirst
NumberOfCopies = MyRS("FieldNameOfCopies")

etc.

You can loop through by changing to

MyRS.MoveFirst
Do
NumberOfCopies = MyRS("FieldNameOfCopies")
MyRS.movenext
Loop Until MyRS.EOF = True

Or if you have a table that has a distinguishing field and you want the copies from that one record then:

Using RecQuant as a variable containing the known ID
For Numerical field ie ID number:
MySearch = "[IDFieldName] = " & RecQuant
MyRS.FindFirst MySearch
NumberOfCopies = MyRS("FieldNameOfCopies")

OR for string based search
MySearch = "[IDFieldName] = '" & RecQuant & "'"
MyRS.FindFirst MySearch
NumberOfCopies = MyRS("FieldNameOfCopies")

NOTE: For string based the string is enclosed by single quotes so = singlequote double quote & RecQuant & double quote singlequote double quote

Hope that something here helps you
 

ANDREW_SAUNDERS

Registered User.
Local time
Today, 04:59
Joined
Mar 11, 2002
Messages
12
Thanks Harry

As I am new to vb code i am having a job to grasp where to put your lines of code

I have tried to make a small function "NoToPrint"()
but am now completely baffled

Perhaps you could give me some more guidence

Thanks
Andrew
 

Users who are viewing this thread

Top Bottom