(Question) auto update field

mikey222

Registered User.
Local time
Today, 08:47
Joined
Nov 4, 2008
Messages
40
I'm trying to setup the system so that when i input the ID of a product the photo link will update the directory containing the product ID.

Say for example

I input A0003 to the field IngPropertType
the directory under memProperyPhotoLink will update to :

ProductsC:\Users\Michaelluk\Desktop\A\A0003.jpg

assume the directory C:\Users\Michaelluk\Desktop\A\XXXX.jpg is fixed

i have tons of product on the list and i would not want to update the directory one by one.

upload2world_62756.jpg


thank you for reading the post this website has helped me a lot...

appreciate
 
Howzit

try, in the After Update of your lngPropertyType...

Code:
dim strFileLoc as string,strFileName as string, strExtens as string

strFileLoc = "C:\Users\Michaelluk\Desktop\A\"  ' Holds default file loc
strFileName = me.IngPropertType                 ' Get value in lngPropertyType
strExtens = ".jpg"             ' What extension

me.memProperyPhotoLink = strfileLoc & strFileName & strExtens
 
thanks for the reply i will work on it and let u know the result

appreciate much ^^
 
I input A0003 to the field IngPropertType
the directory under memProperyPhotoLink will update to :

ProductsC:\Users\Michaelluk\Desktop\A\A0003.jpg

assume the directory C:\Users\Michaelluk\Desktop\A\XXXX.jpg is fixed
If you are saying this rule is always true then you should not store the information. You are effectively storing the same information twice.

You already have the filename stored as IngPropertType and you say the path is always fixed. So you can always calculate the full string on demand. Moreover, you could store the path in some other table as one record so that if you decide to move your files to a new location, you only have to change the path in the one record.

Chris
 
Howzit

try, in the After Update of your lngPropertyType...

Code:
dim strFileLoc as string,strFileName as string, strExtens as string
 
strFileLoc = "C:\Users\Michaelluk\Desktop\A\"  ' Holds default file loc
strFileName = me.IngPropertType                 ' Get value in lngPropertyType
strExtens = ".jpg"             ' What extension
 
me.memProperyPhotoLink = strfileLoc & strFileName & strExtens


thanks for the reply but is the code completed ori have to add in the name for this code...appreciate the reply and sorry for asking so much...^^
 
If you are saying this rule is always true then you should not store the information. You are effectively storing the same information twice.

You already have the filename stored as IngPropertType and you say the path is always fixed. So you can always calculate the full string on demand. Moreover, you could store the path in some other table as one record so that if you decide to move your files to a new location, you only have to change the path in the one record.

Chris


thanks for the reply

i gotta have memProperyPhotoLink on the same page because i have all the information displayed in the forms.

if the system works IngPropertType is empty and different product codes are entered and memProperyPhotoLink will self generate the fixed directory along with the name of the product. jpg
 
Howzit

thanks for the reply but is the code completed ori have to add in the name for this code...appreciate the reply and sorry for asking so much...^^

All you will have to do is create an event procedure, in the after update of your lngpropertytype control. You will need to add code in regards to handling ZLS or null strings in the lngpropertytype.

However Stopher has made some valid points.
  • if the file path is always going to be the same you don't need to store it
  • if the file extension will always be the same, then you will not even require the field
  • An alternative to storing he file location in a table is to create a Public Const to hold the string
  • To view the photo, it will be a variation of the code I supplied together with a Shell command to open the document
 
thank you once again for replying

let me digest the intructions and let ya know the result...

appreciate:)
 
thanks for the code it works perfectly now

cheers
 
Howzit



All you will have to do is create an event procedure, in the after update of your lngpropertytype control. You will need to add code in regards to handling ZLS or null strings in the lngpropertytype.

However Stopher has made some valid points.
  • if the file path is always going to be the same you don't need to store it
  • if the file extension will always be the same, then you will not even require the field
  • An alternative to storing he file location in a table is to create a Public Const to hold the string
  • To view the photo, it will be a variation of the code I supplied together with a Shell command to open the document

hi kiwi
I'm using the code u provided above and i realise that the path would only update if i input characters to lngPropertTypeID from a form but not under the table. Thus, the path would not update when i paste a list of lngPropertTypeID to the form. Is there a way around it? Taken into consideration of your comments if the path is fixed what does it mean its not necessary to store the path? Would it be more appropriate to create a Public Const to hold the string? If so how?

thank you so much for the assistance throughout.

cheers
 

Users who are viewing this thread

Back
Top Bottom