473,480 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Create 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.AssetTag AS
tblInventory_AssetTag, tblInventory.Make, tblInventory.Model,
tblInventory.serial AS tblInventory_serial, tblPrinters.serial AS
tblPrinters_serial, tblPrinters.inkblacknumber,
tblPrinters.inkcolornumber, tblPrinters.tonerblacknumber,
tblSoftware.id AS tblSoftware_id, tblSoftware.AssetTag AS
tblSoftware_AssetTag, tblSoftware.SoftwareA, tblSoftware.SoftwareB,
tblSoftware.SoftwareC, tblSoftware.SoftwareD
FROM tblSoftware RIGHT JOIN (tblPrinters RIGHT JOIN tblInventory ON
tblPrinters.serial = tblInventory.serial) ON tblSoftware.AssetTag =
tblInventory.AssetTag;

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 14762
Why not show the extra information on a 2 sub forms?

"fonzie" <do*******@yahoo.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.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.AssetTag AS
tblInventory_AssetTag, tblInventory.Make, tblInventory.Model,
tblInventory.serial AS tblInventory_serial, tblPrinters.serial AS
tblPrinters_serial, tblPrinters.inkblacknumber,
tblPrinters.inkcolornumber, tblPrinters.tonerblacknumber,
tblSoftware.id AS tblSoftware_id, tblSoftware.AssetTag AS
tblSoftware_AssetTag, tblSoftware.SoftwareA, tblSoftware.SoftwareB,
tblSoftware.SoftwareC, tblSoftware.SoftwareD
FROM tblSoftware RIGHT JOIN (tblPrinters RIGHT JOIN tblInventory ON
tblPrinters.serial = tblInventory.serial) ON tblSoftware.AssetTag =
tblInventory.AssetTag;

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.Setfocus
else
me.txtId.Setfocus
end if

'Do the button thing
me.btnAdd.Enabled = not booenable
me.btnEdit.Enabled = not booenable
me.btnDelete.Enabled = not booenable

me.btnOK.Enabled = not booenable
me.btnCancel.Enabled = 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.Value = "Edit"

'Enable stuff

sEnableControls True

'Populate footer fields

me.txtIdAdd.Value = Me.txtId.Value
me.txtAssetTagAdd.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.Currentdb
'Set up a temporary querydef
set qd = db.Createquerydef("")

'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.txtAssetTagAdd & """, """ &
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*******@yahoo.comwrote in
news:11**********************@e3g2000cwe.googlegro ups.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
5632
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...
4
2093
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...
19
3582
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...
11
18797
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...
5
73174
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
3213
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
4559
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...
5
10868
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...
6
95922
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...
5
2275
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...
0
7051
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,...
0
7054
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,...
0
7097
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...
1
6750
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...
0
6993
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...
1
4794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
193
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...

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.