Insert Records Into Table Based On The Select Criteria From The First Table.
Mar 22, 2005
Hi
I have a small database with 4 tables that I am using for the current problem.
The tables are call, parents, mailman, orders.
Call and parents are related by the call ID (a primary key in the Call table.).
Mailman and orders are related by a Unique Id (a primary key in the mailman table.).
Forms involved are frmmain and frmsub.
Frmmain contains the call table information in the main form and parents information in the subform.
When a user enters a call with call ID and enters the operator name and parents information in the sub form,
When a user clicks the OK button on the main form, necessary changes should take place
if they enter the case type in the sub form part of parent information as ‘missing information’ or ‘missing link’ then the parent information with fields first name, lastname, case type, operator information should be inserted into mailman table in appropriate fields.
Simultaneously a record should be inserted into orders( after the record is first inserted into mailman, since both tables are linked with unique id) with the following information.
Orderid being autonumber.
Uniqueid from the mailman table.
Orderdate system date.
Ordertype should be “Mailman”
View Replies
ADVERTISEMENT
Jan 9, 2007
Newbie question: I have a database where we track dispatched with two tables, one called Slots, the other called Dispatches.
In the slots table there are 2 fields, one called Week (which hold the Monday date for each week in the year), the other called Available (in this field we want to manually enter a number that will tell the system how many dispatches we can do that week). We want to automatically take the number from the Slots.Available and enter X number of blank records in the Dispatch table with the monday date.
How can this be done?
Then we will create a form that can be filled in with the balance of the information.
Thanks
View 3 Replies
View Related
Apr 19, 2007
Hello,
I've looked through the thread and was unable to find exactly what I'm looking for ?
Basically I have a table with multiple fields & records and I would like to key on the ID field which has a slew of different ID's..... these ID's can be the same & show up on the table anywhere from 1 to 600 times.
What I'm trying to do is select each ID and pull only 10 records for each or if less than 10 pull in those as well.
So instead of pulling in the 600 records for that particular ID I only want to pull in 10 of those records, and for the ID that only has the 1 record pull in the info for that as well.
Any help would be greatly appreciated.
Thank you
View 6 Replies
View Related
Jan 4, 2014
WinXPPro Sp3
Access 2007
After some research I thought I had found a neat way to SELECT records from a table based on an 'IN' clause and sort them in the same order as the values for the 'IN' clause... i.e.
Code:
SELECT Unique_No, Table_Name, List_Order FROM My_Table
WHERE Table_Name = 'Titles'
AND List_Order IN (3,1,15,4,5,12,7,2)
ORDER BY INSTR('3,1,15,4,5,12,7,2', List_Order)
Unfortunately, this returns list_order 5 just after 15 and list_order 2 just after 12, thus
List_Order
3
1
15
5
4
12
2
7
View 3 Replies
View Related
Jun 3, 2013
I am trying to create a delete query that, for a given person, deletes records in Table B that do not have a corresponding record in Table A.
Here are the relevant tables:
tblStates holds StateID, StateName, and RegionID (RegionID is a FK to tblRegions).
tblPeopleStates is a junction table between tblPeople and tblStates.
It lists states assigned to people. It has 3 fields: PersonStateID, PersonID, StateID.
tblPeopleRegions is a junction table between tblPeople and tblRegions.
It lists regions assigned to people. It has 3 fields: PersonRegionID, PersonID, RegionID.
For a given PersonID, I need to delete records (i.e., states) in tblPeopleStates whose RegionID is *not* in tblPeopleRegions.
For example, pretend that tblStates shows that State IDs 1, 5, and 6 are all in Region ID (i.e., all have a RegionID = 10).
If Joe (PersonID = 200) has StateIDs 1, 5, and 6 in tblPeopleStates, but doesn't have a record for RegionID = 10 in tblPeopleRegions, I need to delete his three records in tblPeopleStates (i.e., the ones where StateID = 1, 5, and 6).
PersonID will be found on [Forms]![frmMain]![subform1].[Form]![subform2].Form]![PersonID]
View 8 Replies
View Related
Sep 29, 2013
How can I update (some columns) in a table from the same table based on a Criteria column in the same table.
View 2 Replies
View Related
Sep 8, 2014
I have a parent table (tblLabels) and a child table (tblRevision) where the revision history for the parent table is kept.
The parent table is populated via an excel import and may have several records imported at once. Instead of having the user manually enter a new record note in the child table for each record imported into the parent table, I've created a form that collects the necessary data (date, person who added the record, person who authorized the record, and notes) and then creates a revision history for each new record.
This is what I have so far:
Code:
Private Sub cmdAddNotes_Click()
Dim strSQL As String
Dim RevisionDate As String
Dim RevisionRevisedBy As String
Dim RevisionDesc As String
[Code] ....
When I run the code nothing happens. No error, no new records create, etc. My suspicion is that I may need to use an INSERT INTO query instead of an UPDATE query, but I'm not sure how to go about matching up the foreign keys if that's the case.
View 14 Replies
View Related
Mar 29, 2005
I have a UNION of two SELECT queries. It works very well but I need the end-user to be able to modify the data so I am using INSERT INTO tablename. This will work for one query at a time but if I try to use the UNION it reports “Syntax error in FROM clause”. Can you use UNION in this case or can anyone see my error?
The full statement is rather complex, I have added a few spaces and linebreaks to make it readable as follows:
INSERT INTO TableCompleteForMailing
SELECT [Address List].[FamilySurname] AS Surname,
[Address List].[DEARFirstnames] AS FirstName,
[Address List].[Mailing] AS Mailing,
[Address List].[Christmas Mailing] AS OtherMailing, [Address List].[Address 1] AS Address1,
[Address List].[Postcode] AS Postcode
FROM [Address List]
UNION
SELECT [Names].[LastName] AS Surname,
[Names].[FirstName] AS FirstName,
[Names].[MailingList] AS Mailing,
[Names].[Selected] AS OtherMailing,
[Address List].[Address 1] AS Address1,
[Address List].[Postcode] AS Postcode
FROM [Names],[Address List]
WHERE [Names].[AddressListID]=[Address List].[AddressListID]
ORDER BY Surname, FirstName;
View 3 Replies
View Related
Jun 18, 2013
I have a sub form with staff records on it within a main form. I am trying to allow the user to select a record from the sub form and add it to a table, here is my code which, to me, looks correct. However it gives me an error saying "Syntax error in INSERT INTO"
Code:
Private Sub Command3_Click()
Dim dbs As Database
Dim sqlstr As String
Set dbs = CurrentDb
Forename = Nz(Forms!frm_Capex_Submission!frm_staffSub.Form.shy_forename, "")
Surname = Nz(Forms!frm_Capex_Submission!frm_staffSub.Form.shy_surname, "")
[Code] ....
View 1 Replies
View Related
Sep 22, 2015
In my database I have 2 tables that contains values I would like to add if a check box is marked.
Table 1 columns: JobID;JobNumber; Product; Qty.
Table 2 columns: COrderID, JobNumber, QtyChanged, Accepted(Accepted has the check box).Also, there are multiple records for each job number based on how many change orders will be.
I would like to change the value of Qty on Table1 with the values of QtyChanged from Table2 only if the checkbox is marked.
View 6 Replies
View Related
Dec 11, 2006
Hi Guys!
Need help in putting up SQL string.
I have two tables. The first one contains customer information. Primary key is custno. The second one contains customer logins, primary key is also custno.
What I want to do is to view customer information that does not have customer logins.
Is it possible to do in MS Access 2003?
Regards,
Aga
View 7 Replies
View Related
Mar 5, 2008
I have this query below:
INSERT INTO TEST_DOC
SELECT *
FROM MPI_ADDSS_IFF;
I currently have 10 tables in my database (All with the same colunm names and formats) however i want to click a button that will put all the tables into TEST_DOC, instead of doing it one by one. To do this this i would like some code either in SQL or VBA that will do this.
Any ideas or help?
Kind Regards
Hewstone999
View 1 Replies
View Related
Aug 29, 2007
Using MS Access 2002
Need some help trying to filter out some data so it can be deleted from the main table so updated data can be pasted into it that table.
Table name is "dbo_VG_PropertyValues"
AppID - Number
DNIS - Text (This is the column i need filtered)
PropertyName - Text
ProperetyValue - Text
I had a query where i would just type in the 3-4 DNIS numbers that i needed to search for by using "11111" or "22222" or... etc... in the simple query view under criteria..
I'm now getting lists of 50 + numbers i need to do searches for, delete and replace with updated data. I can't run a string of "or" statements on 50+ numbers, it won't allow it. I created a table called 'DNISList" with the 50+ numbers i need to search for out of the "dbo_VG_PropertyValues" table. In the simple query view i linked on the DNIS number from both tables and set the join property to show all the records that matched. Hey it looks good, so far, i got the results i wanted but can't delete anything.
Is there anyway in the criteria field under the column DNIS from "dbo_VG_PropertyValues" where i can so a search on that table without linking the tables? I hope I'm making sense. You know something like:
IN ([DNISList]![TFN])
View 3 Replies
View Related
Apr 10, 2007
hi, i want to convert some below mentioned format into msaccess tables.
the exact scenario is that i have some text files from old applicaiton (pascal based) which is no longer working due to hardware compatibility problem...
which has generated some text files under below mentioned format...
[CLIENT]
L1_CUSTOMER_REFERENCE=AbreyCatherine
L1_TITLE=Ms
L1_SURNAME=Abrey
L1_FORENAME=Catherine
L1_DOB=1 Jul 1957
L2_DOB=9 Jul 1954
L1_ADD1=165 Downhills Way
L1_ADD2=Tottenham
L1_ADD3=London
L1_PCODE=N17 6AH
Q_L1_SEX=F
L1_CLCODE=CA1
L1_MSTATUS=M
L1_RELIGION=Christ.
L1_HASPARTNER=Y
L1_PARTNERNAME=Gian Paolo Caddeo
L1_PHONEH=0181 889 3870
L1_SALUTATION=Catherine
L1_OCC=Management Consultant
L1_EMP_STAT=S
L1_HEALTH=G
L1_SMOKE=Y
L1_NATIONALITY=British
L1_NRA=60
L2_OCC=Heating Engineer
L2_EMP_STAT=S
L2_HEALTH=G
L2_SMOKE=N
L2_NATIONALITY=Italian
L2_NRA=65
FactFindDate=30 Oct 98
TermsOfBusDate=30 Oct 98
LastVisitDate=18 Oct 95
LastLetterDate=14 Dec 99
Consultant=KP
AdminRef=AT
BestCallTime=Evenings
ClientType=UKCL
L1_WillDate=1993
L2_WillDate=1993
MailAllowed=-1
LastMailDone=0
L1_NINumber=YZ070258B
SeparateTax=
ContactFrequency=26
ManualSelect=
ClientLastUpdated=29 Jun100
[CLIENT]
each and every record starts from [CLIENT] and First part is the field and the part " = " is the value for the respective field.
now, i need help in converting that information into msaccess tables and its respective values...
like ...1) first part will become the field of table and
2) 2nd part after " = " will be the value for the respective field of the respective table.
i hope that this has given clear picture. where i want help from an expert...so, kindly help me. That will be great indeed to me.. thanking yours...om
View 9 Replies
View Related
Aug 19, 2015
I'm developing a database for the hospital I work in. One purpose of this is to keep track of patients with temporary invasive devices (there are many types such as urinary catheters, ventilators, etc.), specifically how many days each patient has a device for. Each device is associated with one patient only, but one patient may have many devices. Here's how the associated tables are set up:
1. tblPatients - PatientID (PK), LastName, FirstName, DOB,...
2. tblLocations - LocationID (PK), LocationLabel,....
3. tblDevices - DeviceID (PK), DeviceType, Device, DeviceDesc
4. tblDeviceUse - DeviceUseID (PK), DeviceID (FK), PatientID (FK), LocationID (FK) (where in the hospital was device inserted, e.g., operating room, bedside, etc.), DeviceStartDate, DeviceEndDate
5. tblDeviceDailyLog - DeviceLogID (PK), DeviceUseID (FK), DeviceDate, PatientLocID (FK) (area in the hospital that patient is in)
All primary keys except for PatientID & LocationID are Autonumbers; and the tables are linked appropriately.
Whenever an entry is made into tblDeviceUse, I want there to be new records to be automatically generated in tblDeviceDailyLog for each date between the Start and End Dates. For example, patient A123 had a urinary catheter from 1/1/2000 to 1/10/2000 that was inserted while the patient was in the ICU, but the patient was moved to the Medical Ward on 1/7/2000. So tblDeviceDailyLog should have 10 new records associated with this device, one for each calendar day, with the appropriate location for each day.
View 3 Replies
View Related
Dec 9, 2014
I am reading through a table looking for duplicate values in the FullName text field. I want to store in a new table the duplicate records I find, storing just the MemberNumber and the FullName. When the VBA code runs and finds duplicates, the SQL statement to insert a new record into the Duplicates table asks for the value of LastMemberNumber and LastFullName when it already has the values and has displayed them in the message boxes! What am I doing wrong?
The code is:
Private Sub Command0_Click()
Dim rs As DAO.Recordset
Dim dbs As Database
Dim LastMemberNumber As Integer
Dim LastFullName As String
[code]....
View 7 Replies
View Related
Oct 3, 2007
I have two tables [Reviews] and [Results].
When a Review has a Status = 'Not Accepted' then there should be one or more records in [Results] that indicate what the result of the review was.
I want to structure a query to perform a data integrity check to select any Review ID that satisfies the following criteria:
- The Review Status = 'Not Accepted'
- There are zero records in [Results] for that ReviewID
I can't figure out how to do it.
Here is an example of the tables where all record are OK...
[Reviews]
ID...Status
1....Accepted
2....Not Accepted
3....Accepted
4....Not Accepted
5....Not Accepted
6....Accepted
[Results]
ReviewID....ResultID
2................5
2................6
4................3
5................3
5................7
Here is how [Results] would look if there is a data integrity problem, where the results for Review 5 are missing....
[Results]
ReviewID....ResultID
2................5
2................6
4................3
So I want to structure a query that would return the following...
ReviewID
5
Because this is a Review with Status = 'Not Accepted' but there is no corresponding record(s) in [Results].
I guess in plain English it would be like this...
SELECT ReviewID
FROM [Reviews]
WHERE (ReviewID is in [Reviews]) AND (ReviewID is NOT in [Results])
Can this be done in a single SQL query?
View 10 Replies
View Related
Aug 1, 2005
Is anybody can help me to solve problem with inserting empty record between two records in unordered (non-indexed) table - like in Excel work sheet.
Regards,
Gennady
View 4 Replies
View Related
Aug 11, 2013
I have two tables, one is GENETIC and the other one is BoneSampleDNAprofile. Both tables have the field CY-Code. I want to create small form with 2 text box fields and one command button on the form to be able to insert CY-Code from the table GENETIC to designated DNA_LAB_Code in the table BoneSampleDNAprofile.
In that small form I would type DNA_LAB_Code and CY-Code where after pressing command button will insert CY-Code for the designated DNA_LAB_Code. This is continuous process after our Laboratory receive results from DNA laboratory. I have attached two .png files which are example of two tables.
View 2 Replies
View Related
Apr 22, 2013
I am fairly new to Access and I would like to create a form to allow users to create their own query. I would like to allow users to select multiple fields (perhaps with checkboxes?) from all possible fields in a table to return either all data from that field or narrow their search by inputting certain criteria or choosing from a drop down into a text box. Is this possible in Access and any detailed specifics on how to achieve this?
View 3 Replies
View Related
Apr 28, 2005
I've got a database that pulls from a table. One of the options on the table is pending or complete. Right now, there are over 1000 records because they are all stored in the same record. I'd like to move the completed items to a different table.
Can this be done? If so, what steps do I need to take to do this?
Thanks!
View 3 Replies
View Related
Apr 15, 2014
I'm trying to copy records from another base into existing table in current base by:
Code:
DoCmd.RunSQL ("INSERT INTO pivot (RFO_CLIENT_ID, FOLDER_DATE_CREATE, start_time, end_time) SELECT (RFO_CLIENT_ID, FOLDER_DATE_CREATE, start_time, end_time) FROM svod IN 'Z:NPSNPS - Operator - 1.accdb' ")
But it doesn't run. Says insert into syntax error.
View 6 Replies
View Related
Jul 4, 2005
Hi all,
I have a table which contains business details (name, address etc) and also a field for clients. I then have a table which contains client details. Is there anyway I can click a button on a form containing business details which brings up a form containing the clients which would allow me to click the clients I want to be inserted onto the clients field on the business details table?
Does anybody have an example of this.
Thanks for your help!
View 1 Replies
View Related
Nov 25, 2014
How to get my query to run from criteria based on a combobox from another table. I have a field "prac" that has entries such as JF, MG, PM, RJ etc.
My query has the criteria for prac as [Forms]![PracReportPrint]![PracChoice].
PracChoice is the name of the combobox.
If I specify a valuelist for the combobox the query works. I created a different table just for a list of practitioners that contains only an index key and practitioners (JF, MG, PM, RJ, and so forth). When I set the combobox to table/query and select practitioners from my other table I get the correct list,b ut the query doesn't seem to detect what is selected from the combobox.
View 2 Replies
View Related
Jun 30, 2005
Hi all,
Been pulling my hair out about this for a while, so i hope someone's feeling kind:
http://www.agga.dsl.pipex.com/pics/AWF01.gif
I'm using the BHRefPrefix to build part of a reference number. The Principal and Site exist on a separate form, and i need to use both as criteria in order for the correct BHRefPrefix to be returned.
I sort of get it working using two joins, but it doesn't let me add any new records. I've tried straight queries, queries with DLookup expressions, and i just can't get what i need.
Pete
View 3 Replies
View Related
May 8, 2007
Hi all,
Very very new to Access, moved department a week ago and inherited a couple of databases that need tweaking. Although I'm learning I am stuck by something very simple and can't find it by searching this forum or Google :)
I have a query that originates from 2 tables, there is one custom record made from 2 of the fields -
Free Stock: [stk_stkqty]-[stk_allstk]
Now I want a record that shows -
Product where the free stock = backorder stock
so theroetically my guess as a beginner is -
SELECT * FROM [Product] WHERE [Free Stock] <> [Back Order]
But it fails miserably on syntax. Can someone point me in the right direction, and I apologise for my lack of understanding in advance.
Boofuls :)
View 5 Replies
View Related