Query Problem: Records Linked To Records
Oct 31, 2007
Hi,
I was wondering if anyone would be kind enough to help me out on this problem I have.
I have a table:
---------------------------------
Source | LinkedTo
---------------------------------
A1 B2
B2 C1
B2 C2
C1 D1
C2 D2
C2 D3
B2 D4
A1 D5
Another table:
-------------------------------
Item | Load
---------------------------------
D1 2
D2 4
D3 6
D4 8
D5 10
So looking at the tables,
C1 = 2
C2 = 4+6 = 10
B2 = C1 + C2 + D4 = 20
A1 = 20 + 10 = 30
Here, there are 4 levels that I have to go into to get the grand total. If I did not know how many levels there were, how would I be able to do this through code? through queries if possible??
If anyone could help, that would be great! Thank you in advance.
Bear
View Replies
ADVERTISEMENT
Jan 16, 2008
I have attached an image of the 2 tables concerning my question.
The main "transaction" table is the tblAssessments and a linked table tblRisks drives a subform - showing multiple Risks per assessment.
The field "OccupantID" identifies the facility where Assessments are done (there are other tables, of course).
I am using an OccupantID "00000" to store templates - pre-filled assessments with most common options selected.
I am trying to develop code and/or query or SQL that would do this:
copy all templates (records from OccupantID 00000) and corresponding sub-records from tblRisks into the same tables, but under a different (selected by user) OccupantID.
I have no problem just using an Append Query (actually a SQL statement in VBA with variable parameters), but that only lets me copy into 1 table - so I can copy just the tblAssessments records.
but how do I then copy the tblRisks related records and make sure I attach them to the correct AssessmentID?
View 5 Replies
View Related
Jun 16, 2014
How can I get a Query Criteria To Select All Records or specific records in query design section.
I have a table that shows many departments with credit card transactions. I like to run a query to see specific department, or have an option to see all the departments when the query is run.
View 2 Replies
View Related
Aug 10, 2005
I've posted in general because I really don't know what approach is best for this requirement. I can't even come up with a meaningful, yet succinct title.
Here's the problem. I have tables:
tblApplication - defines an application (name)
tblServer - defines a server
tblInstance - defines a partition on a server (defined in above table).
tblApplicationInstance - defines a specific instance of an application on an instance on a server (i.e. ties the above three tables together)
The tblApplicationInstance table has an autogenerated ID field as primary key, and foreign keys to tblApplication and tblInstance (and thus through this to tblServer).
All well and good. Now the next table
tblApplicationUse - defines that a specific project (a foreign key to another table but I don't think it is an important factor here) is using a specific application instance over a date range.
The question. How to allow entry of new tblApplicationUse records without having to find and enter the ID from tblApplicationInstance. Rather, I want the user to specify the Application, Server and Instance, but be limited to only those that are defined.
I tried a simple query, thinking it may allow me entry, but not so. I've been building some simple forms for query parameter prompting lately but am fairly inexperienced with these. The crudest form of prompting I can think of is to simply apply a drop-down to the ID field (in tblApplicationUse) and use a multi-column format here. But it ends up very wide and is less than ideal.
Can anybody give me ideas on the 'proper' way to do this?
View 1 Replies
View Related
Oct 17, 2005
I am having difficulty deleting records in a linked DBF (standalone) table. The table links fine. I can run a delete query and the records appear to be deleted when I view the table from within Access. However, when I view the table outside of Access, the records that I thought were deleted are still there. The only way I can actually delete the records, is to import the table, delete the records and then export the table as a new DBF.
Can someone tell me why deleting from the linked table isn't working?
Thanks,
Sup
View 1 Replies
View Related
Apr 2, 2006
I have done everything I can think of to remedy this, but I can't figure out why this is happening. I have a linked table from excel that contains 5 fields for each record. I have a table in access with matching records and 20-30 fields. The linked spreadsheet is used when adding records. I have a query that queries both tables to get all data from both and a form based on that query where others can pertinent data for the records resulting from the query. My problem is that when I open the form the new records that were added in the linked file are there but all the fields from the access table cannot be updated. I have looked every place I know to look for record locks, read only options, everything I can think of why i cannot update these records and I am coming up empty. I checked my join properties and selected the only one that actually displays the linked records when the query is run (not sure the name of the join but it's #2 of 3 join properties options (in Access 2002). maybe I am just overlooking something simple? Do you have any ideas what I can do here?
Thanks!
View 1 Replies
View Related
Apr 22, 2006
Hi,
Relevant to this query are two tables, tblNames and tblLinks.
I've been trying, with a very limited understanding, to generate a list of every tblName.Name where tblName.NameID IS NOT in tblLinks.NameID.
Is this something I can do in the query design view or do I need to work with raw SQL?
Any tips appreciated:)
View 2 Replies
View Related
Jun 5, 2006
Greetings all.
I'm posting this question here as it pertains to my form but it could go in tables section as well.
I developed a prototype app in Access and have just finished upscaling it
to Sybase 12.5. When I open up the associated form to add records, I am unable to do so. The built in button that allows you to do so is greyed out.
When I go into the table directly, again, no ability to add recs.
I've never come across this so if anyone has any experience with this, any help would be most welcome.
TIA,
Tim
View 1 Replies
View Related
Jan 29, 2008
Hi all,
I've got one question again.
Let's say. I've created several tables to store data for several categories.Note: there is no relationship between each table.In each table, there is the date field in which the record is created.
Then I want to make another daily record form that is to find records from all categories which is created at the current date.
Is this possible to search records from various tables and combine them to show in one form or report?
Can anyone help me in this case?
thanks in advance.
View 3 Replies
View Related
Jan 17, 2013
I'm new to Access2007. I created 5 tables all related to each other in series with one-to-many joins (type 2 and all enforcements on).So an Id in table 1 can show up several times in table 2, and the same is true from tables 2 to 3, 3 to 4 and 4 to 5.I want to enter new records in such way that I can see all tables at once. I tried to do that with a query, but I can only modify records, not add new ones.I have no problem adding records to individual tables but have not figured out how to do it to this All-tables query.
View 2 Replies
View Related
Feb 16, 2006
I have an Access database with linked tables from Sybase SQL Anywhere, via an ODBC data source. I have just linked the tables recently, all the data used to be in native Access tables. It is fairly common for members of our team to open these tables in datasheet view, and copy/paste several records to create new records, then edit a few fields on the new records. This used to work fine with native Access tables, but when we try it with the linked tables we either get an ODBC error - "primary key value already exists" or the new records show up with #Deleted.
The root of the problem is this: In the old Access tables, the primary key was an autonumber field, and Access was smart enough to assign new ID's when you copy/pasted records. In the linked table, the primary key is type "Number" in Access, and Access is not smart enough to let Sybase assign new ID's when you copy/paste records in datasheet view. Access is trying to force the existing ID's into the primary key field, and Sybase says "too bad so sad".
Of course, I could just write some quick append queries to copy/paste the data. And in the short term, that's exactly what I will have to do. But is there any way, long term, to allow members of my team to do it the "quick & dirty" way by copy/pasting in datasheet view? I have tried to change the primary key to an autonumber field in design view, but Access doesn't allow that. Is there a way to do it in code, or a way to force Access to allow Sybase to always handle the primary key field?
View 1 Replies
View Related
May 25, 2007
Hi,
I have a lot data to append to ODBC linked table in MS Access. I want to know that which way is faster to append the records.
if I append the data into ODBC linked table,
1) create the one query (append) to insert the records into ODBC linked table
2) use the VBA code (DAO/ADO) to insert the records into ODBC linked table
which way is rather faster?
View 1 Replies
View Related
Jan 7, 2014
I have a main form with a subform. The subform has linked tables from the main form. People are on the main form with the index PersonId and they are linked to incidents by IncidentId.
I want to put in two buttons.
First put a print report button for each subform whereby it will only produce a report for the records I can see on screen . i.e. if a person is linked to two incidents I just want the report for those two incidents.
Secondly I would also like a print all button on the subform where it prints reports containing the current IncidentId number.
View 2 Replies
View Related
Sep 24, 2014
Is it possible to add new records to a linked table ? i tried it out but new records is not possible, is there a workaround for this.
View 8 Replies
View Related
Mar 4, 2015
I am looking for a query that will return records from a table that have related records in another table. Opposite to the Unmatched Query Wizard.I have two tables: tblSupplier and tblSupplierProducts.The two tables are related by the field "SupplierId".I need the query to only return Suppliers that have Products.
View 3 Replies
View Related
Jul 30, 2015
I have an access db with a linked table (to Sharepoint) which contains about 15000 records. I have to copy those records to the local access db. To do this I have a bit of VBAcode. It works, but for each next record that is copied it takes a bit longer. When starting the program the records are copied quite fast, but soon you see it slowing down until after a couple of thousand records it just goes too slow to be usefull, meaning it would take a lot of days to copy all records.
What I now do is let it copy 500 records and exit ms-access completely and then start it again and let it copy the next 500 records. This works but is tedious as I have to do it about 35 times. Why this gradual slowdown occurs?
The VBA code is pretty straightforward.(I use VBA because I do a bit of data wrangling while reading in the values of the records)
Code:
Dim importdb1 As DAO.Database
Dim rsimportdb1 As DAO.Recordset
Dim i As Double
Set importdb1 = CurrentDb
Set rsimportdb1 = importdb1.OpenRecordset("2015")
Set rsMain = CurrentDb.OpenRecordset("tbl_import")
[code]....
View 3 Replies
View Related
Jul 21, 2006
I am rebuilding an application for a client and I have an Access table that I am using as a temporary table. Once the user is done entering information into the temporary table through a form, the user presses an update button that appends the records using an Append Query in Access to an SQL Server Table.
The following error message occurs:
"ODBC -- insert on a linked table 'linked tblname' failed.
[Microsoft][ODBC SQL Server Driver][SQL Server] Explicit value must be specified for identity column in table 'linked tblname' when IDENTITY INSERT is set to ON. (#545)
I am using a form, subform combination to record a bill with many details. The bill summary is posted into a tbl_TransactionsMain table in SQL Server using the ADO AddNew method. The PK for the tbl_TransactionsMain is then entered into the temporary table in Access. When the temporary table records are appended into tbl_TransactionDetail the error message occurs.
What is also interesting is while typing out this post I thought to test the error by manually trying to run the query. The query worked like a charm! :confused: When the orginal error occurred off of the form I tried to run the query manually and it failed. I am guessing that this might have something to do with the ODBC timeout.
I think SQL Server/ODBC connection is not liking how I have a set of records in an Access table with foreign key numbers assigned when I am attempting to append the records. I am new to SQL Server and any ideas are most appreciated! :)
View 1 Replies
View Related
Jan 20, 2006
My problem has now moved on to a form issue which means no one has been able to answer is in the queries section of the forum as there is no way around it using queries so i hope you can help. All information is available on this thread. Thanks, Sci http://www.access-programmers.co.uk/forums/showthread.php?t=100376
View 3 Replies
View Related
Dec 12, 2013
I'm developing a system which uses linked tables (to an Oracle database) and subforms. I'm trying to add functionality to create new child records, but am running into errors when saving these records.
Parent table is PATIENT, child is DIAG. I have my DIAG Form_Current event set up to detect whether a record is new. When this happens I populate the DIAG foreign key with the relevant PATIENT primary key, and run a query to the underlying database to find out the next DIAG primary key. I then populate all the necessary fields.
On attempting to leave this record however, I get an ODBC call failed error, telling me that the the primary key constraint in the database has been violated. The reason is that Access isn't saving the record to the underlying database. I've tried to prompt this using Me.Dirty and RunCommand acCmdSaveRecord, but both of these just generate type mismatch errors.
What am I missing? Is there some particular set up for linked tables and creating new sub-records that I need to put in place?
View 1 Replies
View Related
Jun 15, 2013
In an Access 2010 form is it possible to export select records and fields in those records to a specific location?
Code:
Set objDialog = Application.FileDialog(4)
With objDialog
.AllowMultiSelect = False
.Title = "Please select a File"
.InitialFilename = "C:"
.Show
If .SelectedItems.Count = 0 Then
MsgBox ("Action Cancelled")
Else
[code]....
The user can select the directory using the code above, but can specific fields in records be exported to a excel workbook in that selected directory?For example, if the are 5 records in the database can the fields LastName,FirstName,BirthDate in records 1,2,3 be exported to Setup.xlsx in that selected directory?
View 1 Replies
View Related
Nov 21, 2012
I have a table (tbl Team Info) which contains names and codes for teams within my business (>400 records) and another table (tbl Process) which contains a list of high level tasks (30 records).
I need to create something where for each team name 9in tbl Team Info) I can map them to the tasks that they undertake (in tbl Process) and assign a percentage of time then spend on each task. Each team could map to several different tasks.
View 3 Replies
View Related
May 29, 2014
In my simple database (attached), I need to mass duplicate Tasks and their Notes.
I have three tables: tbTasks (PK: Task_ID), tbNotes (PK: Note_ID), jtbTaskNotes (FKs: Task_ID and Note_ID). jtbTaskNotes is my many-to-many junction table that ties Tasks to Notes.
The main form (fmTasks), bound to tbTasks, has a subform (sbfm_TaskNotes) that displays notes associated with each Task. On themain form,you select which Tasks you want duplicated via a checkbox. The append query (quCopyTasks) will duplicate all tasks that have the checkbox checked. All good there. However, I can't figure out how to also duplicate each task's Notes.
I found Allen Browne's solution [URL] ....., but that only handles duplication of one record at a time, whereas I need to duplicate many records at a time (sometimes 10+ records). How do I go about duplicating multiple Tasks and their associated Notes?
Before you ask "why are you duplicating records?": There are times when tasks need to be re-accomplished and therefore need to have a new record. It's easier to duplicate records than it is to hand-jam everything again.
View 5 Replies
View Related
Jun 27, 2013
I am trying to get the records on start and end date, still showing error no records found.
My code is like this:
Private Sub Command90_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strReport As String
Const strcJetDate = "#dd/MM/yyyy#"
[code]...
View 1 Replies
View Related
Mar 22, 2013
One shows my form with the Transporters Subform with 3 entries, and 1 entry.The three line items that say "Transporter" are in one subform. I used this code
Code:
Private Sub Form_Current()
If Me.RecordsetClone.RecordCount >= 3 Then
Me.AllowAdditions = False
End If
End Sub
to limit the number of records I can add to 3 or less.My issue is that I lost the blank text box that allows you to add another record. So, if I only have one Transporter listed, there's no box to let me add a second or third.I have the following properties for the Transporters Subform set to "Yes":
Data Entry
Allow Additions
Allow Deletions
Allow Edits
Allow Filters
View 3 Replies
View Related
Nov 16, 2004
I have built a qry that initially shows the correct information. For example.
tblContent has 289 records with a Type = Class.
I built a Query to select from tblContent Type = Class and I get 289 records. I add additional criteria of Progress <>"Not Scheduled", I then get 206 records. I then add additional criteria Last Name <>"Demo" And <>"Care" And <>"Support". This brings up 200 records, but the query appears to duplicate each record 3 times. I do not have 3 of the same types of records.
The SQL Statement is below
SELECT tblProfile.LoginName, tblProfile.FirstName, tblProfile.LastName, tblProfile.Organization, tblProfile.CostCenter, tblContent.Title, tblContent.Type, tblContent.Code, tblContent.[Date Assigned], tblContent.[Date Started], tblContent.[Last Accessed], tblContent.Progress, tblContent.[Date Completed]
FROM tblProfile INNER JOIN tblContent ON tblProfile.LoginName = tblContent.LoginName
WHERE (((tblProfile.LastName)<>"Demo" And (tblProfile.LastName)<>"Care" And (tblProfile.LastName)<>"Support") AND ((tblContent.Type)="Class") AND ((tblContent.Progress)<>"Not Scheduled"));
The qry is named qryPhysical Class. I have provided the link to view the database. Can you help me?
http://briefcase.yahoo.com/turnerbkgabrobins
Thank you in advance for your assistance.
View 1 Replies
View Related
Jan 12, 2014
All seemed to be working well, however, I noticed that all my subtable records in the database are exporting with each Primary table record. In my output, I'm looking to see each primary table record followed by one or more subtable records from a one to many relationship.
(Office 2010) Access/Word
Private Sub cmdPrint1_Click()
Dim objWord As Word.Application
Dim docm As Word.Document
Dim db As DAO.Database
Dim rstLandSales As DAO.Recordset
[Code] ......
View 14 Replies
View Related