Need help in pulling info from different sources for a code.

M

Michael

I have the following code in the default value of a textbox on a form. I am
looking to use the code to mark the week and day number plus the providers
(Fornitore) code that is drawn from a dropdown list on the form and also the
product code (Prodotto) also drawn from another dropdown list.

I do not get any errors when I inserted the code but I always only get the
week number and weekday number (4405 for today)and nothing else.


=Format(DatePart("ww";Now();2;3);"00") & Format(DatePart("w";Now();2);"00")
& [Fornitore].[Column](1) & [Prodotto].[Column](1)


thank you for your help
Michael
 
M

Michael

I think I am closer, I have added Format to the fields... but still not
right

=Format(DatePart("ww";Now();2;3);"00") & Format(DatePart("w";Now();2);"00")
& "-" & Format([Fornitore].[Column](1)) & "-" &
Format([Prodotto].[Column](0))
 
J

John Vinson

I have the following code in the default value of a textbox on a form. I am
looking to use the code to mark the week and day number plus the providers
(Fornitore) code that is drawn from a dropdown list on the form and also the
product code (Prodotto) also drawn from another dropdown list.

I do not get any errors when I inserted the code but I always only get the
week number and weekday number (4405 for today)and nothing else.


=Format(DatePart("ww";Now();2;3);"00") & Format(DatePart("w";Now();2);"00")
& [Fornitore].[Column](1) & [Prodotto].[Column](1)

The Prodotto combo box will not have any value when the form is
opened, or a new record is created - and that's the only time that the
DefaultValue will be applied.

This kind of "Intelligent Key" is generally considered a Bad Idea.
Storing the part information and the date of the transaction
redundantly in your table is unwise. I'd suggest instead simply
storing the date of the transaction using Date() (only use Now() if
you want to store both the date and time accurate to microseconds);
generate this composite as a calculated field whenever it's needed.

John W. Vinson[MVP]
 
M

Michael

Thanks john,
Is there anyway to do this getting the information from the dropdown list? I
need to create this number as a way to follow the product by the name and
where is came from. These are things the company must do by law in case
there is a bad product. It is perishable items. The time is not relevant so
I can use the Date() but my problem is to follow the product.

thanks
Michael

John Vinson said:
I have the following code in the default value of a textbox on a form. I
am
looking to use the code to mark the week and day number plus the providers
(Fornitore) code that is drawn from a dropdown list on the form and also
the
product code (Prodotto) also drawn from another dropdown list.

I do not get any errors when I inserted the code but I always only get the
week number and weekday number (4405 for today)and nothing else.


=Format(DatePart("ww";Now();2;3);"00") &
Format(DatePart("w";Now();2);"00")
& [Fornitore].[Column](1) & [Prodotto].[Column](1)

The Prodotto combo box will not have any value when the form is
opened, or a new record is created - and that's the only time that the
DefaultValue will be applied.

This kind of "Intelligent Key" is generally considered a Bad Idea.
Storing the part information and the date of the transaction
redundantly in your table is unwise. I'd suggest instead simply
storing the date of the transaction using Date() (only use Now() if
you want to store both the date and time accurate to microseconds);
generate this composite as a calculated field whenever it's needed.

John W. Vinson[MVP]
 
M

Michael

John I got it to show on the form bye placing it in the control source, but
is there a way to save this or do i need to regenerate it each time I need
it? I will be using this number to scan with a barcode reader, so it would
be easier if it was somewhere in the database all the time.
Michael


Michael said:
Thanks john,
Is there anyway to do this getting the information from the dropdown list?
I need to create this number as a way to follow the product by the name
and where is came from. These are things the company must do by law in
case there is a bad product. It is perishable items. The time is not
relevant so I can use the Date() but my problem is to follow the product.

thanks
Michael

John Vinson said:
I have the following code in the default value of a textbox on a form. I
am
looking to use the code to mark the week and day number plus the
providers
(Fornitore) code that is drawn from a dropdown list on the form and also
the
product code (Prodotto) also drawn from another dropdown list.

I do not get any errors when I inserted the code but I always only get
the
week number and weekday number (4405 for today)and nothing else.


=Format(DatePart("ww";Now();2;3);"00") &
Format(DatePart("w";Now();2);"00")
& [Fornitore].[Column](1) & [Prodotto].[Column](1)

The Prodotto combo box will not have any value when the form is
opened, or a new record is created - and that's the only time that the
DefaultValue will be applied.

This kind of "Intelligent Key" is generally considered a Bad Idea.
Storing the part information and the date of the transaction
redundantly in your table is unwise. I'd suggest instead simply
storing the date of the transaction using Date() (only use Now() if
you want to store both the date and time accurate to microseconds);
generate this composite as a calculated field whenever it's needed.

John W. Vinson[MVP]
 
J

John Vinson

John I got it to show on the form bye placing it in the control source, but
is there a way to save this or do i need to regenerate it each time I need
it? I will be using this number to scan with a barcode reader, so it would
be easier if it was somewhere in the database all the time.
Michael

I see you reposted and got a good answer downthread, so I'll just
recommend you use that technique.


John W. Vinson[MVP]
 
M

Michael

thanks again
michael
John Vinson said:
I see you reposted and got a good answer downthread, so I'll just
recommend you use that technique.


John W. Vinson[MVP]
 

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