Results 1 to 8 of 8
  1. #1
    hodagh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    4

    registration database

    Hi,
    I have a database which has my student information(name,family,field of study,...)
    to take exam I have to assign a unique number to each of them based on their field of study, for example chemistry students between 1000 and 2000, physics student between 2000 and 3000 , and so on
    (and these IDs should be between 1000 and 999999 )
    anyone knows how should I do it? (I don't know any programming in access!!)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You want to programatically create unique ID. This will require VBA. Why is this necessary? Why not just allow autonumber and another field for the field of study?

    Common topic. Search forum or Google

    Review https://www.accessforums.net/access/...ers-21361.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    hodagh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    4
    I was told that each field of study should have its own student number
    so it's just possible with VBA??
    I wanted to do with nested if like:
    IIf([field of study]="chemistry", =Int ((2000 - 1000 + 1) * Rnd + 1000),IIf([field of study]="math",= Int ((3000 - 2000 + 1) * Rnd + 2000))) and so on
    but it doesn't accept my formula! have any idea??

  4. #4
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    What happens when more than 1000 students are taking Chemistry?

    Is this a real system or a school project?

    If it is a real system then you need to redesign your table structure - if it is a school project your exam board or teacher needs to do some research. (I am a teacher who has suffered exam board stupidity with incorrect data models and specifications).

  5. #5
    hodagh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    4
    Quote Originally Posted by SteveH2508 View Post
    What happens when more than 1000 students are taking Chemistry?

    Is this a real system or a school project?

    If it is a real system then you need to redesign your table structure - if it is a school project your exam board or teacher needs to do some research. (I am a teacher who has suffered exam board stupidity with incorrect data models and specifications).
    yeah this is the real system and they want to use it in lower scale systems
    so is the nested if in this way correct?

    to have a validation rule for student ID, I'm trying to say [student ID] Between 1000 And 2000 but it doesnt accept . what is the correct way for "Between And"??
    Thanks in Advance

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Code is required to save generated ID. I use only VBA, don't know if macro can do this.

    Remove the = sign from in front of each Int.

    Why the 2000-1000, 3000-2000 terms. They just evaluate to 1000.

    How many fields of study? Nested IIf is supposed to have a limit of 7 levels.

    BETWEEN AND won't work in IIf expression.

    Use <= and >=, like:

    x >= And x<=

    You are trying to use Rnd() to generate a unique identifer? I would not trust Rnd() to not duplicate.

    Did you review the referenced link? And did you consider Steve's question about hitting ceiling of each study field number set?
    Last edited by June7; 11-05-2012 at 12:11 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    hodagh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    4
    Quote Originally Posted by June7 View Post
    Code is required to save genered ID. I use only VBA, don't know if macro can do this.

    Remove the = sign from in front of each Int.

    Why the 2000-1000, 3000-2000 terms. They just evaluate to 1000.

    How many fields of study? Nested IIf is supposed to have a limit of 7 levels.

    BETWEEN AND won't work in IIf expression.

    Use <= and >=, like:

    x >= And x<=

    You are trying to use Rnd() to generate a unique identifer? I would not trust Rnd() to not duplicate.

    Did you review the referenced link? And did you consider Steve's question about hitting ceiling of each study field number set?
    yes I read it but I don't think that's gonna work for me . so I found this VBA code and works fine but I don't know how to connect it to my student ID field in the database . how do I do it ??


    Sub GenerateRandomUnique() Dim lng As Long
    Const lngMax As Long = 100
    Const lngMin As Long = 1
    With CreateObject("Scripting.Dictionary")
    Do While .Count <= lngMax - lngMin 'removed the greater than symbol
    lng = Rnd * (lngMax - lngMin) + lngMin 'removed the +1
    .Item(lng) = Empty
    Loop
    MsgBox Join(.Keys, " ")
    End With
    End Sub

    http://www.excelfox.com/forum/f13/ra...excel-vba-608/

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Here is how I manage generating unique ID: http://forums.aspfree.com/microsoft-...ta-403208.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Registration Database with Family and Individual Tables
    By mcbowlby in forum Database Design
    Replies: 2
    Last Post: 08-18-2012, 05:58 AM
  2. 2010 Active X registration
    By cvegas in forum Programming
    Replies: 0
    Last Post: 09-16-2011, 09:39 AM
  3. database registration failures
    By rocheiro in forum Access
    Replies: 0
    Last Post: 02-10-2011, 09:08 AM
  4. Registration of Attendees
    By camende in forum Programming
    Replies: 1
    Last Post: 06-30-2010, 03:47 PM
  5. Registration Form
    By nengster in forum Forms
    Replies: 0
    Last Post: 02-16-2009, 04:22 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums