Bruce, In the expression builder I pasted the code and changed the name
of the text box. I placed it in the after update in the dropdown of the
prodotto. When I try to run the program, I get and error message that MS
Office Access can't find the macro 'If isNull(Me.'
thanks again for your help
michael
"BruceM" <
[email protected]> ha scritto nel messaggio
So you are saying that the number is to be created based on criteria
such as date, and thereafter the number that was first created for the
record will remain a part of that record. In this case storing the
value is legitimate. You cannot calculate it when needed based on date
unless you are prepared for the number to change every time you view
the record or print a report.
Your number is based in part on combo box selections, it seems. That's
OK, but do you need the number to change if those selections ever
change? Will they ever change, as for instance if there is an error in
the original record, or for any other reason?
By the way, you can re-create it as needed only if there is a date
field in the original record, and if that and the content of the combo
boxes will not change.
To create the number you could use the after update event of one of the
combo boxes (untested air code):
If IsNull (Me.MyTextBox) then
Me.MyTextBox = Format(DatePart("ww"; Date; vbMonday;
vbFirstFullWeek); "00") & _
Format(DatePart("w"; Date; vbMonday); "00") " " &
Format([Fornitore].Column(1);"00") & _
" " & Format([Prodotto].Column(1);"000")
End If
This assumes that MyTextBox is a text box bound to the field in which
you would store the number. Note that the underscores are used only
for line wrapping in the code window, for convenience of viewing the
code. By the way, I don't how to translate the "3" for week of the year
to VBA, so I added vbFirstFullWeek and left it at that. Note that
Column is not enclosed in square brackets.
Thank Bruce,
This number will always remain the same. It becomes the ID number for
this pallet and the product that is on the pallet. For this reason I
would like to keep the number with the other information on this form.
I know I can recreated it when needed, but since it is a number that
will never change with any calculation I just thought it would be
easier to keep in a field.
This number will be used as the barcode for this pallet and my barcode
program requires me to assign a field that holds the value of the
barcode and also later on in the process it will be used to track the
product after it has been processed and packaged and sent to stores.
michael
"BruceM" <
[email protected]> ha scritto nel messaggio
I assume that you do not want the number changing when you view the
record from day to day, in which case it makes sense to save it. You
could save it by using a command button, or in the after update event
of a combo box. Do you want the value to change when the date changes
or when a combo box value changes, or is this a value that is to be
created when the record is created, after which it is to remain the
same?
This is kind of a cross post from my own post of a few days ago, I
have the code that is presented below that gives me a number based
on some choices made in different drop down list.
I know the conventional wisdom is to not save information you
already have in the database. but I need this field to print and
read barcodes on other forms and reports.
I have this code as my control source on the text box and I would
like to save the results in a field in the table this form is
derived from.
=Format(DatePart("ww";Date();2;3);"00") &
Format(DatePart("w";Date();2);"00") & " " &
Format([Fornitore].[Column](1);"00") & " " &
Format([Prodotto].[Column](1);"000")
thank you for your help.
Michael