A Microsoft Office (Excel, Word) forum. OfficeFrustration

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   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

data checking



 
 
Thread Tools Display Modes
  #1  
Old April 27th, 2010, 05:35 PM posted to microsoft.public.access.tablesdbdesign
dutchgenius
external usenet poster
 
Posts: 1
Default data checking

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
  #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

  #3  
Old April 27th, 2010, 11:53 PM posted to microsoft.public.access.tablesdbdesign
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default data checking

If I understand you, I think you need a compound index set to No Duplicates.

--
Build a little, test a little.


"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

 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.