By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Unique ID's with Code 1- whatever

P: n/a
I have an application that will have a Male and Female, the Date of Birth and
finally a total number of animals. I would like to create a unique ID for each
of the animals using this last number; example

ABC - XYZ - 00/00/2004 - 12 would be the ID for the litter, I want to create
unique ID's for all 12 animals. This is derived from number of Females, number
of Males

Female =ABC - Male=XYZ - Date of Birth=00/00/2004 - Total Females & Males 12
ABC - XYZ - 00/00/2004 - 01
ABC - XYZ - 00/00/2004 - 02
ABC - XYZ - 00/00/2004 - 03
ABC - XYZ - 00/00/2004 - through 12 programatically with code. Any help would
be greatly appreciated.

Michael
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lumpierbritches wrote:
I have an application that will have a Male and Female, the Date of Birth and
finally a total number of animals. I would like to create a unique ID for each
of the animals using this last number; example

ABC - XYZ - 00/00/2004 - 12 would be the ID for the litter, I want to create
unique ID's for all 12 animals. This is derived from number of Females, number
of Males

Female =ABC - Male=XYZ - Date of Birth=00/00/2004 - Total Females & Males 12
ABC - XYZ - 00/00/2004 - 01
ABC - XYZ - 00/00/2004 - 02
ABC - XYZ - 00/00/2004 - 03
ABC - XYZ - 00/00/2004 - through 12 programatically with code. Any help would
be greatly appreciated.

Michael


Something like (air code, uses DAO, minor mods needed for ADO, assumed
form textboxes with names [txt...])

Dim strKeyPrefix as String
Dim lngBaby as Long
Dim rst As Recordset
Dim db As Database
strKeyPrefix = [txtMother] & "-" & [txtFather] & "-" & [txtDOB] & "-"
set db=CurrentDb()
set rst = db.OpenRecordset("NameofBabyTable")
with rst
For lngBaby = 1 to [txtNumberOfBabies]
.AddNew
!IDField = strKeyPrefix & Format(lngBaby,"00")
' other fields to suit
.Update
Next
.Close
end with
set rst=nothing
set db=nothing

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.