Hello I'm new to developing databases in Access and using Access2003. I have a dataset with a few many to many relationships that I have created linking tables for to make multiple 1:M relationships.
My problem is trying to figure out a set of forms and subforms for this data in which the users can enter new data in a straightforward way. In my dataset there are: Buildings, Contacts, addresses for buildings and contacts, and different types of contacts. The contact types are super, manager, and volunteer.
Here are the relationships:
- A building has more than one contact and a contact can be associated with more than one building. (M:M)
- contact can be more than one type (1:M)
- an address can be associated with more than one contact (1:M).
- a building is associated with one address. (1:1)
Here is how I set up my tables:
tblBldg
BldgID PK
BldgName
(other unique bldg attributes)
AddrID FK
tblContacts
ContactID PK
ContactNmLast
ContactNmFirst
(other unique contact attributes)
tblContactTypes
TypeID PK
TypeNm
tbl Addresses
AddrID PK
StreetAddr
City
State
ZipCode
tblContactTypeU Q
ContactTypeID PK
ContactID
TypeID
tblContactTypeA ddr
ContactTypeID
AddrID
tblBldgContactT ype
BldgID
ContactTypeID
Specifically, I tried to set up a form starting with Buildings that had subforms in which you can view the building address and the multiple contacts associated with a building and their attributes (including their addresses - a nested subform under Contacts). When I add a new building name in the main form and then try to add an address for that building in the adress subform (to be entered in the address table) it will not let me b/c there is not already an ID for the Address that I want to add. Also, when I try to add a contact and its related data in the contact subform, the linking tables do not update (the tbl BldgContactType table or a record is not added to the tblContactTypeU Q table). Same for the table linking ContactTypeID and AddrID.
Please advise!
thanks in advance.
Bridget
Aug 17 '07
22 3228 FishVal 2,653
Recognized Expert Specialist
The error message is:
The text you entered isn’t an item in the list.
Select an item from the list or enter text that matches one of the listed items.
It appears as though it refuses to enter the data into the table after telling you it did enter the new data.
Hi, Bridget.
I beg your pardon for the delay. Was very busy.
The cure seems to be simple so far.
Invoke "Requery" method on the combobox as soon as new record was appended to the table.
Smthng like
after DoCmd block.
Thanks! I'm now getting an error message that says you have to "save the field before running the requery". I tried to use DoCmd's toopen the table into which the new data is written and then save and close, but this did not work. Is there another way in which I can save the field first before running the requery?
Hi, Bridget.
I beg your pardon for the delay. Was very busy.
The cure seems to be simple so far.
Invoke "Requery" method on the combobox as soon as new record was appended to the table.
Smthng like
after DoCmd block.
I'm now trying an alternate way to add new data to a combo box:
I created an "Add Address" button. If the address is not in the combo box, the user clicks on the button, which opens a form "frmAddress " to directly enter data into tblAddr1f. The user can add the new record and click a "Done" button to close the form. On exit, I run the requery. Now when I click on the Addr1 combo box in the frmBuildings the new address is present. I have two questions about this tactic, however:
1) Is there a way to automatically populate the Addr1 control with the newly added address in the record from which I clicked the "Add Address" button?
- Right now, it adds the address to the combo box, but I have to go an select it from the list.
- Another odd thing is that when I close the frmAddress after adding a new record, I view the record from frmBuildings that I was working on. However, when I click on the combo box to select that new address, it jumps me to the first record in the frmBuildings. How do I keep the record I was working on active?
Thanks again in advance for any insight!
Bridget
PS if this is a terribly inefficient way to do udpate a combo box, and I should return to the previous method, please let me know! I just couldn't get the other to work... :(
Thanks! I'm now getting an error message that says you have to "save the field before running the requery". I tried to use DoCmd's toopen the table into which the new data is written and then save and close, but this did not work. Is there another way in which I can save the field first before running the requery?
FishVal 2,653
Recognized Expert Specialist
Thanks! I'm now getting an error message that says you have to "save the field before running the requery". I tried to use DoCmd's toopen the table into which the new data is written and then save and close, but this did not work. Is there another way in which I can save the field first before running the requery?
Hi, Bridget.
Plz, post additional information concerning combobox Addr1 - RowSource - if it is table post table metadata, if it is query post SQL
- BoundColumn
FishVal 2,653
Recognized Expert Specialist
I'm now trying an alternate way to add new data to a combo box:
I created an "Add Address" button. If the address is not in the combo box, the user clicks on the button, which opens a form "frmAddress " to directly enter data into tblAddr1f. The user can add the new record and click a "Done" button to close the form. On exit, I run the requery. Now when I click on the Addr1 combo box in the frmBuildings the new address is present. I have two questions about this tactic, however:
1) Is there a way to automatically populate the Addr1 control with the newly added address in the record from which I clicked the "Add Address" button?
- Right now, it adds the address to the combo box, but I have to go an select it from the list.
- Another odd thing is that when I close the frmAddress after adding a new record, I view the record from frmBuildings that I was working on. However, when I click on the combo box to select that new address, it jumps me to the first record in the frmBuildings. How do I keep the record I was working on active?
Thanks again in advance for any insight!
Bridget
PS if this is a terribly inefficient way to do udpate a combo box, and I should return to the previous method, please let me know! I just couldn't get the other to work... :(
Both methods are quite acceptable. The question is what method looks you more suitable? There is even 3rd method. Retrieve into combobox list with a specific row, let us say "Add new address", which when chosen opens form for entering new address record?
What seems to you more suitable? Choose one from the three.
Anyway additional info concerning the combobox would be useful. See my previous post.
Good morning,
The SQL for my Row Source is:
SELECT qryAddr1f.Addr1 , qryAddr1f.Addr1 ID
FROM qryAddr1f
ORDER BY qryAddr1f.Addr1 ;
The Bound Column is 2
(The Column width is 1";1" ( I remember getting an error message at some point that the Column Width had to match the bound column or something like this...)
Bridget
Hi, Bridget.
Plz, post additional information concerning combobox Addr1- RowSource - if it is table post table metadata, if it is query post SQL
- BoundColumn
Hi FishVal,
Right now, I am liking the button method - maybe because I actually got it working - sort of... :) If I can fix the issues in my previous post on the button method (copied again below) I'd probably go with this option... As always, any insight greatly appreciated!
Bridget
1) Is there a way to automatically populate the Addr1 control with the newly added address in the record from which I clicked the "Add Address" button?
- Right now, it adds the address to the combo box, but I have to go an select it from the list.
- Another odd thing is that when I close the frmAddress after adding a new record, I view the record from frmBuildings that I was working on. However, when I click on the combo box to select that new address, it jumps me to the first record in the frmBuildings. How do I keep the record I was working on active?
Both methods are quite acceptable. The question is what method looks you more suitable? There is even 3rd method. Retrieve into combobox list with a specific row, let us say "Add new address", which when chosen opens form for entering new address record?
What seems to you more suitable? Choose one from the three.
Anyway additional info concerning the combobox would be useful. See my previous post.
FishVal 2,653
Recognized Expert Specialist
Good morning,
The SQL for my Row Source is:
SELECT qryAddr1f.Addr1 , qryAddr1f.Addr1 ID
FROM qryAddr1f
ORDER BY qryAddr1f.Addr1 ;
The Bound Column is 2
Bridget
Hi, Bridget.
I generally implement the same combo configuration. The code below is a working NotInList handler from one of my DBs. -
Private Sub Addr1_NotInList(NewData As String, Response As Integer)
-
-
Dim RS As New ADODB.Recordset
-
-
Response = acDataErrContinue
-
-
If MsgBox("Dou you want to add " & NewData & " to item names list", _
-
vbInformation + vbYesNo, "Add new item confirmation") = vbNo Then Exit Sub
-
-
Response = acDataErrAdded
-
-
With RS
-
.Open Me.Addr1.RowSource, CurrentProject.Connection, _
-
adOpenDynamic, adLockOptimistic
-
.AddNew
-
![Addr1] = NewData
-
.Update
-
Me.Addr1 = ![Addr1ID]
-
.Close
-
End With
-
-
Me.Addr1.Requery
-
-
Set RS = Nothing
-
-
End Sub
-
BTW what do you mean by this.
(The Column width is 1";1" ( I remember getting an error message at some point that the Column Width had to match the bound column or something like this...)
To the best of my knowledge column width doesn't have to match anything. At least I've never encountered problem with this.
Regards,
Fish
FishVal 2,653
Recognized Expert Specialist
Hi FishVal,
Right now, I am liking the button method - maybe because I actually got it working - sort of... :) If I can fix the issues in my previous post on the button method (copied again below) I'd probably go with this option... As always, any insight greatly appreciated!
Bridget
1) Is there a way to automatically populate the Addr1 control with the newly added address in the record from which I clicked the "Add Address" button?
- Right now, it adds the address to the combo box, but I have to go an select it from the list.
- Another odd thing is that when I close the frmAddress after adding a new record, I view the record from frmBuildings that I was working on. However, when I click on the combo box to select that new address, it jumps me to the first record in the frmBuildings. How do I keep the record I was working on active?
Hi, Bridget.
Plz post all the code of button_Click procedure.
Basically you need to update your combo with AddrID. But as soon as AddrID is Autonumber you can't do it before you've append new record to tblAddr.
If you append new record via separate form, then there are at least two different approaches. - the form where you enter new address update combobox "Addr1", referencing to it via "Forms" collection, e.g.
-
Forms![Main form name]![Subform name]![Addr1] = <New value>
-
- the button_click code opens the form in modal mode and then updates combobox "Addr1" retrieving last [Addr1] with DMax function.
Anyway forms are separate objects and synchronization between them will require a bit of coding. For example the code must handle such a situation when the form was opened but no record was appended.
Regards,
Fish
Hi FishVal.
Here is the OnClick code for the btnAddAddr in the main form: -
Private Sub btnAddAddr_Click()
-
On Error GoTo Err_btnAddAddr_Click
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
stDocName = "frmAddr1"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
DoCmd.GoToRecord , , acNewRec
-
Exit_btnAddAddr_Click:
-
Exit Sub
-
-
Err_btnAddAddr_Click:
-
MsgBox Err.Description
-
Resume Exit_btnAddAddr_Click
-
-
End Sub
-
This opens frmAddr1 in which I can add a new address.
Then there is a "Done" button in the frmAddr1
The code here for this button is: -
Private Sub btnDone_Click()
-
On Error GoTo Err_btnDone_Click
-
-
DoCmd.Close
-
-
Exit_btnDone_Click:
-
Exit Sub
-
-
Err_btnDone_Click:
-
MsgBox Err.Description
-
Resume Exit_btnDone_Click
-
-
End Sub
-
What happens after I click "Done" is that the frmAddr1 closes and you are back looking at the main form. However, the new address is not showing in the control and when i click on the control to select it, the form jumps back to the first record.
Bridget
Hi, Bridget.
Plz post all the code of button_Click procedure.
Basically you need to update your combo with AddrID. But as soon as AddrID is Autonumber you can't do it before you've append new record to tblAddr.
If you append new record via separate form, then there are at least two different approaches.- the form where you enter new address update combobox "Addr1", referencing to it via "Forms" collection, e.g.
-
Forms![Main form name]![Subform name]![Addr1] = <New value>
-
- the button_click code opens the form in modal mode and then updates combobox "Addr1" retrieving last [Addr1] with DMax function.
Anyway forms are separate objects and synchronization between them will require a bit of coding. For example the code must handle such a situation when the form was opened but no record was appended.
Regards,
Fish
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve Jorgensen |
last post by:
Terminology question:
Is there a term for a set of records related directly or indirectly by key
value in several tables? For example, a single invoice record and its line
item records -or- a single customer, the customer's orders, the order lines
for those orders, the customer's invoices, and the invoice lines for those
invoices.
I'm thinking the term might be graph, but I'm not at all certain of this.
|
by: SuryaPrakash Patel via SQLMonster.com |
last post by:
Hello,
There are three tables:
OS-GroupOFCompanies (Table1)
GoC_GroupOFCompaniesID (PK)
OS-Organization (Table 2)
Org_OrganizationID (PK)
|
by: misscrf |
last post by:
I am currently working on a database, in 3rd normal form, which is for
candidates who apply for a job with the law firm that I
workd for. My issue is with good form design.
I have a main form. Then I have 3 pages on a tab control ( 4 if the
type of candidate validates that is is to be shown) Each page
has a subform. The subforms can be either single or continuous, I
think I am still deciding what I want to lock down this entry...
|
by: dskillingstad |
last post by:
I've been struggling with this problem for some time and have tried
multiple solutions with no luck.
Let me start with, I'm a novice at Access and I'm not looking for
someones help to design my database,just help in getting me pointed in
the right direction.
I have a database with 8 tables, which from what I have read, cannot be
linked on a single form, and be updatable. I have created a query
which includes all 8 tables, and then...
|
by: Jason L James |
last post by:
Hi all,
does anyone know if I can create a dataview
from multiple datatables. My dataset is constructed
from four separate tables and then the relationships
are added that link the tables together. To make
data entry easier I would like to combine selected
columns from the four tables onto a single dataview that
could be used as the datasource for a datagrid
control. The distinct updates, insert ans delete
| |
by: shriil |
last post by:
Hi
I have this database that calculates and stores the incentive amount
earned by employees of a particular department. Each record is
entered
by entering the Date, Shift (morn, eve, or night) and the 'employee
name'. There is another table which assigns an ID to the Shifts, i.e.
1,2 and 3 for morn, eve & night shifts respectively. From the mother
table, the incentive is calculated datewise for each employee as per
his shift duty. In...
|
by: BASSPU03 |
last post by:
I had to present my DB today, but was granted a chance to fix something about it. In order to fix something, I added something...something that is giving me more trouble than it should. I have to present again tomorrow. Quick assistance would be greatly appreciated.
I have three forms (one main form and two subforms) with the following fields:
frmResultsFY
FiscalYear
sfrmResultsAgencies
FiscalYear
Agency
|
by: cannonpm |
last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a
search form modeled after Allen Browne's search form (http://
allenbrowne.com/ser-62.html). It works well except for records which
have multiple related records in 1:many relationships and many:to:many
relationships. To view my results, I created a query called qryAllData
which contains all of the data from several tables for each record.
For example, say I have one...
|
by: 6afraidbecause789 |
last post by:
Think school - students - discipline interventions - misbehaviors -
staff for this one....On a mainform frmStudentInterventions, I have
linked a subform (sfrmMisbehaviors) with another subform
(sfrmInterventions) with the Child and Master fields
"InterventionID." This is tested and works - as users click through
the continuous list of interventions, the continuous list of
misbehaviors changes per intervention. Now, I need to link another...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |