If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > help with required field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-02, 11:57
tessie tessie is offline
Registered User
 
Join Date: Oct 2002
Location: Arkansas
Posts: 9
Question 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!
Reply With Quote
  #2 (permalink)  
Old 12-16-02, 12:00
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
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
Reply With Quote
  #3 (permalink)  
Old 12-16-02, 12:00
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
U can also set up the column in the table to not accept a null and code your own error msg......
Jim
Reply With Quote
  #4 (permalink)  
Old 12-16-02, 15:49
tessie tessie is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 12-16-02, 15:58
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On