473,699 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

One form -> multiple tables

Is it possible to have a data entry form where the information is
stored in several different tables (5 or 6)? I have an inventory
database where Table1 stores all of the data common to all entries,
Table2 stores only the extra info relevant to items that are TYPEA,
Table3 stores only the extra info relevant to items that are TYPEB, and
so on. All relationships are setup (one-to-one) between the main table
(Table1) and all the other tables with the required fields. I can get
it to work with Table1 and one other table, but as soon as I add a
third table it won't let me enter data. Is it a problem in the join
statement? This is the record source SELECT statement that doesn't
work:

SELECT tblInventory.id AS tblInventory_id , tblInventory.As setTag AS
tblInventory_As setTag, tblInventory.Ma ke, tblInventory.Mo del,
tblInventory.se rial AS tblInventory_se rial, tblPrinters.ser ial AS
tblPrinters_ser ial, tblPrinters.ink blacknumber,
tblPrinters.ink colornumber, tblPrinters.ton erblacknumber,
tblSoftware.id AS tblSoftware_id, tblSoftware.Ass etTag AS
tblSoftware_Ass etTag, tblSoftware.Sof twareA, tblSoftware.Sof twareB,
tblSoftware.Sof twareC, tblSoftware.Sof twareD
FROM tblSoftware RIGHT JOIN (tblPrinters RIGHT JOIN tblInventory ON
tblPrinters.ser ial = tblInventory.se rial) ON tblSoftware.Ass etTag =
tblInventory.As setTag;

I will entertain most suggestions, but using subforms is not an option.
Hopefully someone can point me in the right direction.

Sep 8 '06 #1
8 14782
Why not show the extra information on a 2 sub forms?

"fonzie" <do*******@yaho o.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Is it possible to have a data entry form where the information is
stored in several different tables (5 or 6)? I have an inventory
database where Table1 stores all of the data common to all entries,
Table2 stores only the extra info relevant to items that are TYPEA,
Table3 stores only the extra info relevant to items that are TYPEB, and
so on. All relationships are setup (one-to-one) between the main table
(Table1) and all the other tables with the required fields. I can get
it to work with Table1 and one other table, but as soon as I add a
third table it won't let me enter data. Is it a problem in the join
statement? This is the record source SELECT statement that doesn't
work:

SELECT tblInventory.id AS tblInventory_id , tblInventory.As setTag AS
tblInventory_As setTag, tblInventory.Ma ke, tblInventory.Mo del,
tblInventory.se rial AS tblInventory_se rial, tblPrinters.ser ial AS
tblPrinters_ser ial, tblPrinters.ink blacknumber,
tblPrinters.ink colornumber, tblPrinters.ton erblacknumber,
tblSoftware.id AS tblSoftware_id, tblSoftware.Ass etTag AS
tblSoftware_Ass etTag, tblSoftware.Sof twareA, tblSoftware.Sof twareB,
tblSoftware.Sof twareC, tblSoftware.Sof twareD
FROM tblSoftware RIGHT JOIN (tblPrinters RIGHT JOIN tblInventory ON
tblPrinters.ser ial = tblInventory.se rial) ON tblSoftware.Ass etTag =
tblInventory.As setTag;

I will entertain most suggestions, but using subforms is not an option.
Hopefully someone can point me in the right direction.

Sep 8 '06 #2
Using subforms isn't an option, I need it to be on one form.

I will entertain most suggestions, but using subforms is not an option.
Hopefully someone can point me in the right direction.
Sep 8 '06 #3
fonzie wrote:
Is it possible to have a data entry form where the information is
stored in several different tables (5 or 6)?
What about an unbound form (you can have bound listboxes and combos)?
On the OK button run insert statements to plop the screen data into the
appropriate tables.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Sep 8 '06 #4
I am very close with the setup I have now, the problem is when I add
the third table to the select statement I can only view the results in
the form, I can't add or edit of the information. Is this by design?
Does my SELECT statement need to be changed somehow?

Sep 8 '06 #5

fonzie wrote:
I am very close with the setup I have now, the problem is when I add
the third table to the select statement I can only view the results in
the form, I can't add or edit of the information. Is this by design?
Does my SELECT statement need to be changed somehow?
I could be completely outta my mind, but I don't think Access is
designed to do what you are attempting to do. I guess you could base a
form on 3 tables, but I try to stay away from that kind of thing. As
you've found, it's not hard once you have a form with more than one or
two tables as the recordsource, you're going to have problems with the
recordset being updateable. It's the nature of the relational beast, I
think. If I were you, I'd rethink my form design because you may be
asking something that's not impossible, but certainly not easy.

Sep 8 '06 #6
fonzie wrote:
I am very close with the setup I have now, the problem is when I add
the third table to the select statement I can only view the results in
the form, I can't add or edit of the information. Is this by design?
Does my SELECT statement need to be changed somehow?
Based on your other response to Ron, ie restricted to one form, no
subforms, here's what I would do.

I'll assume the fields identified in your join statement are prmary
keys. This is critical.

1) Design your select statement so it displays the records you want it
to. You've pretty much done that. Don't worry that the query doesn't
allow you to edit/add records.

2) Create a continuous form with a footer that displays the fields you
want. You've a fair number of fields that might lend themselves to
having a subform datasheet, but since that's out of the question, you
want to make this a continuous form so that you have a "bare footer"
showing. Maybe two or more rows in the detail section might be
necessary, perhaps with Asset tag in bold or a different colour or
something. Use text boxes to display the information for each record in
the form detail section.

3) Make sure the name property of each text box is NOT, repeat NOT the
same as the controlsource field from the query. I usually name my text
boxes txtFieldName.

4) Set the add, and delete properties on your form's property data tab
to NO. What we are going to do is set up fields in your footer and five
buttons for adding, editing and deleting records.

5) In the tag property of each text box you've just created in the
detail section, write "Display". Make sure all these text boxes are
enabled. You should also lock them - you don't want users to try and
change data in the detail section - that's what the footer secction will
be for.

6) In the footer, duplicate the controls in the detail section BUT MAKE
SURE THERE ARE *NO* CONTROLSOURCES in each text box. In other words,
you turn on your form and there's blank spaces in the controls on the
footer. Name each control as per 3, above, perhaps with Add as a
suffix, such as txtFieldNameAdd .

7) If you want to restrict users to specific data instead of the free
form a text box can potentially allow:

-a) use a combo box with a row source from one a query but with no
controlsource;
-b) use the afterupdate event to restrict what is allowed; and/or
-c) Add constraints in your table field properties with appropriate
messages.

8) For every text/combo control in the footer, mark the Tag property
"DataEntry" and disable them all.

9) Create 5 buttons in the footer. Three are labeled add, edit and
delete. Enable these buttons. Two are labeled OK and cancel and are
disabled. You can use images that clearly indicate the function of each
button.

10) Add a text box that is invisible in the footer and call it txtAddEdit.

11) What you want to be able to do is click one of the three buttons and
have the detail section freeze. Use a sub in the form something like
(All of the following is air code - no error handling will be offered here):

Sub sEnableControls (booEnable as Boolean)

'booEnable is passed as True to enable when adding/editing record
'and false to disable when cancelling or
'accepting addition/edit of a record

dim Ctl as Access.Control

'Enable dataentry controls

for each ctl in me.controls
if ctl.controltype = acTextBox or ctl.controltype = accombobox then
if ctl.tag = "dataEntry" then crl.enabled = booenable
end if
next

'Switch focus to one of the fields in the footer
'so that the following does not throw an error like
'"You can't disable the control that has the focus"

if booenable = True then
me.txtIdAdd.Set focus
else
me.txtId.Setfoc us
end if

'Do the button thing
me.btnAdd.Enabl ed = not booenable
me.btnEdit.Enab led = not booenable
me.btnDelete.En abled = not booenable

me.btnOK.Enable d = not booenable
me.btnCancel.En abled = not booenable

End Sub

When the Edit button is clicked, it loads the current values into the
controls of the footer:

Sub btnEdit_Click

'Set txtAddEdit to "Edit" so app knows what to do
'When OK is pushed.

me.txtAddEdit.V alue = "Edit"

'Enable stuff

sEnableControls True

'Populate footer fields

me.txtIdAdd.Val ue = Me.txtId.Value
me.txtAssetTagA dd.Value = Me.txtAssetTag. Value
'etc, etc - for the add button, set these all to null,
'ie, empty

End Sub

Now, when you have done your additions, etc, set up the ok button as
follows:

Sub btnOK_CLick

dim strS as string
dim db as dao.database
dim qd as dao.querydef

If me.txtAddEdit = "Add" then
'This will mean create and execute three insert statements

'Set Up the db and querydef

set db = Access.Currentd b
'Set up a temporary querydef
set qd = db.Createqueryd ef("")

'Let's do tblInventory, first

strS = "INsert into tblInventory (" & vbcrlf
strs = strs & "id, AssetTag, " & vbcrlf
strs = strs & "Make, Model, serial)" & vbcrlf
strs = strs & "Select " & vbcrlf
strs = strs & me.txtIdAdd & ", """ & me.txtAssetTagA dd & """, """ &
me.txtMakeAdd & vbcrlf
strs = strs & me.txtModelAdd & ", """ & txtsERIALAdd & """"

with qd
.SQL = strs
.returnsrecords = false
.execute dbfailonerror
end with

'Repeat the above 11 lines for the other tables.

Else
'This will be fr three update statements - you can figure that out.
end if

'IF you get this far, you've been successful, hurrah!
'Enable stuff

sEnableControls False

Exit_Proc

qd.close
set qd = nothing
db.close
set db = nothing

End sub

You can fill in the blanks. I rushed this together before going home
from work. Check things carefully, it's all air code.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Sep 8 '06 #7
Tim Marshall wrote:
I'll assume the fields identified in your join statement are prmary
keys. This is critical.
Actually it's not. See ya, have a good weekend!
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Sep 8 '06 #8
"fonzie" <do*******@yaho o.comwrote in
news:11******** **************@ e3g2000cwe.goog legroups.com:
Using subforms isn't an option, I need it to be on one form.
>
I will entertain most suggestions, but using subforms is
not an option.
Hopefully someone can point me in the right direction.
In this case, you have only the options of 1) using a subform, 2)
not showing the data.

Which is the predominant option?

I'd take the subforms over saying I can't do it any day.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 9 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5648
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change to the appropriate mode and test the html form it gave me an 500 internel server error. I really need it to be done soon, I would not post here before I test it as much as I can,
4
2125
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the same amount of Line Items. If I have all 20 Line Items, it works great. var sub1 = form.Line_Item_Subtotal1.value var sub2 = form.Line_Item_Subtotal2.value var sub3 = form.Line_Item_Subtotal3.value var sub4 = form.Line_Item_Subtotal4.value
19
3606
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the thing you know ;-) After discovering that access 2000 support form properties (I'm a
11
18832
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that they are too big and wind up covering up some of the fields on the main form. Is there any good code out there that works in a similar fashion that will also either a) stretch the form width wise on widescreens or b), rely on height rather than...
5
73209
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
6
3227
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
4
4576
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET forum). I don't use server controls in it (apart from Page). The problem occurs on the page where visitor can post a new messages. Basically, it's a form with couple of
5
10903
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I have a form that has a button. ( this form is a child form of a parent form ( main form ). Anway...in this child form I have a button, and if clicked a bunch of code will get executed. I would like to show a Progress Bar / form in modal/ShowDialog...
6
96123
NeoPa
by: NeoPa | last post by:
Introduction The first thing to understand about Sub-Forms is that, to add a form onto another form takes a special Subform control. This Subform control acts as a container for the form that you want to act as a Sub-Form of the main one. That is to say, if you wanted frmB to act as a Sub-Form of frmA, then you would create a Subform control on frmA (in this example we'll call it sfmB). Subforms have a .Form property which contains a...
5
2301
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an email. however all the information is missing form the email I only get the first form text field?? #!/bin/perl # ------------------------------------------------------------
0
8687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8617
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.