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  

Table Design



 
 
Thread Tools Display Modes
  #1  
Old April 25th, 2005, 12:36 AM
external usenet poster
 
Posts: n/a
Default Table Design

I have a table for Equipment in a plant that contains all information about
the machine in general such as Production Number, Serial Number, Date
Purchased ect. Each machine has several sections that make up the whole such
as Feed section, Print Section and Cut Section. I want to have the main
machine with a number such as 123.000 and each part to list under that
machine such as (Feed) will be 123.001 and so forth. Each parent machine
already has an Equipment ID number that is an auto-number (existing DB) so
that ID 1 will be machine 123, 2 will be another machine. Is there a way to
"nest" the child machine under the parent without creating a table for each
section and each machine?

Whole Machine 123
Feed 123.001
Print 123.002
Cut 123.003


Thanks in advance for your help.

Richard


  #2  
Old April 27th, 2005, 04:28 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Sun, 24 Apr 2005 19:36:05 -0400, wrote:

I have a table for Equipment in a plant that contains all information about
the machine in general such as Production Number, Serial Number, Date
Purchased ect. Each machine has several sections that make up the whole such
as Feed section, Print Section and Cut Section. I want to have the main
machine with a number such as 123.000 and each part to list under that
machine such as (Feed) will be 123.001 and so forth. Each parent machine
already has an Equipment ID number that is an auto-number (existing DB) so
that ID 1 will be machine 123, 2 will be another machine. Is there a way to
"nest" the child machine under the parent without creating a table for each
section and each machine?


This should be stored in TWO fields, not in one. If the main machine
is 123, then the child machine table should have a foreign key to the
EquipmentID field (containing 123), and a *SEPARATE* field ComponentNo
let's call it; this should be a simple Long Integer number field.

To populate it, use a Form to do your data entry; base the Form on the
Equipment table and a Subform on the Components table. In the
subform's BeforeInsert event put code like

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!ComponentNo = NZ(DMax("[ComponentNo]", "[Components]", _
"[EquipmentID] = " & Me!EquipmentID)) + 1
End Sub

This will look up the largest existing component number for this
EquipmentID (and the NZ() function will return 0 if there are no
components entered yet), add one, and store that value.

You can concatenate the two fields for display purposes using an
expression like

[EquipmentID] & "." & Format([ComponentNo], "000")

John W. Vinson[MVP]
 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking some expert advice. HD87glide Using Forms 14 March 23rd, 2005 11:11 PM
unable to repair inobox Sudheer Mumbai General Discussion 1 February 20th, 2005 12:55 PM
Manual line break spaces on TOC or Table of tables Eric Page Layout 9 October 29th, 2004 04:42 PM
Autonumber Ally H. General Discussion 7 August 27th, 2004 04:51 PM
COMPARE THE TWO TABLES Stefanie General Discussion 0 June 4th, 2004 04:36 PM


All times are GMT +1. The time now is 08:31 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.