Hello,
In my Access database, I have a table with a list of photographs which are either taken in Black & White, Colour Slide, Colour Print, or Digital. Each type of film can have more than one roll of film associated with it.
When a user has entered the required data on the form and has clicked a button to confirm this, I want to create an unique ID number from a combination of three fields: FilmType (BW, CS, CP or DP), FilmNo (currently as an integer) and the PhotoNo (again an integer). I want to create a format of the type "BW03056", or "CS01345", where BW etc = film type, the two digit number "01, 02" etc. = film number (no more than 99 films will be used), and the three digit number "012", "346" etc. = photo number. This String will also be used to rename the photos as they are scanned in, allowing them to be clearly referenced when they come to be archived (hence AutoNumber is not an option).
I am fairly new to VBA, and while I can create a unique Photo ID using the following code, I do not know how to ensure each ID is in the format outlined above:
Private Sub Command42_Click()
Dim strFilmType As String
Dim intFilmNo As Integer
Dim intPhotoNo As Integer
strFilmType = FilmType
intFilmNo = FilmNo
intPhotoNo = PhotoNo
PhotoID = strFilmType & intFilmNo & intPhotoNo
End Sub
Another issue is that digital photographs will not have a film number, and in this case, I want it to accept '0' in the 'FilmNo' field, and pass this to the PhotoID field as "00". I know I need to create an 'on error' condition in this sub, I just haven't done that yet.
I hope this is clear. Thank you in advance for your help.
Rebecca
Start Free Trial