Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    Arkansas
    Posts
    9

    Question Unanswered: help with required field

    I have a field (dropdown) that must be populated before moving off the record. Where do I put the code? I had it on Unload of the form, but that doesn't catch the empty field when moving to the next record.

    I have this code in On Unload
    If Me.cboStatus = "J" And IsNull(cboDA.Column(1)) Then

    MsgBox "Please Enter The Juvenile's Current Dorm Assignment, or select 'Unknown'."
    cancel = true
    Me.cboDA.SetFocus

    I assume I need the same code (minus the cancel=true) somewhere else for when the form is not closed.. but the user clicks new record or next record, etc..
    Help is appreciated!

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    How do you navigate to the next record? Thats where I would put it ie if you ahve a next button. You may also want to set a default to the combo of Unknown.
    Jim

  3. #3
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    U can also set up the column in the table to not accept a null and code your own error msg......
    Jim

  4. #4
    Join Date
    Oct 2002
    Location
    Arkansas
    Posts
    9
    I set the field as required in the table. When I add a record without keying to the required field.. it proceeds as normal... but it doesn't save the record.

    I need more details on what to do. They move off of the record by one of several ways.
    1. The record selector
    2. the Create New button
    3. closing the form

    I may make it simple and do as suggested.. default to Unknown.. if they don't change that.. they will get lots of Unknowns on their report.. not my problem.

  5. #5
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by tessie
    I set the field as required in the table. When I add a record without keying to the required field.. it proceeds as normal... but it doesn't save the record.

    I need more details on what to do. They move off of the record by one of several ways.
    1. The record selector
    2. the Create New button
    3. closing the form

    I may make it simple and do as suggested.. default to Unknown.. if they don't change that.. they will get lots of Unknowns on their report.. not my problem.
    you can put the code
    if combo.value = "Unknown" then
    unknownmsg =MsgBox("Unknown Datatype", vbOKCancel, "Unknown Data")
    if vbcancel then
    end
    else docmd.close acform "FormName"

    in the on close of form and on the on click of the cmd button.
    The only way i know how to get that command in the record selection is to creat all of those buttons and then put this in with that code
    the easiest way to do it would default it and let them deal with it.
    hope this give you an idea
    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •