Thread: data checking
View Single Post
  #2  
Old April 27th, 2010, 06:34 PM posted to microsoft.public.access.tablesdbdesign
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default data checking

If each record is for information about a Box, you may have something like
this for tables:

tblBox
BoxID (primary key, or PK)
BoxNumber
Description
etc.

tblSlots
Slot ID (PK)
BoxID (link to tblBox)

Have a main form based on tblBox, with a subform based on tblSlot. If the
slot numbers are 1-16, you could have a text box (txtSlot) bound to SlotID.
In the form's Current event:

Me.txtSlot.DefaultValue = _
Nz(DMax("[SlotID]","[tblSlots]","[BoxID] = " & Me.Parent.BoxID),0) + 1

The underscore is a line continuation character for VBA. It is not needed,
but I used it here in case of word wrapping in the newsreader making the code
hard to read.

The above assumes BoxID is a number field. I don't know if BoxID should be
the same as BoxNumber or not. It depends in part on whether there could be
more than one record in tblBox for a given box number.


dutchgenius wrote:
I am using a simple form for the user to enter data into the main table. one
of the fields available is "Box Number" and each of these boxes holds 16
items. i use a separate field "slot number" to designate where each item is
stored in the box. is there a way to store the data when entering it into
the form, so that each slot number can only be used on time for each box
number?

i want to create some sort of data checker or error message that will tell
the user "this slot number in box X is already used".

any ideas how i can set this up? cheers


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...esign/201004/1