Help With UPDATE Utilizing A Working SELECT
Jan 29, 2008
I'm very new to Access 2000. I'm working with 3 tables.
I finally got this sql statment to work:
SELECT [tlkp.Language].[LangID],
[tblRawData].[LangName],
[tblApplication].[AppID]
FROM (tlkpLanguage INNER JOIN tblRawData
ON [tlkpLanguage].[LangName]=[tblRawData].[LangName])
INNER JOIN tblApplication ON [tblRawData].[AppID]=[tblApplication].[AppId]
How can I change it to UPDATE?
I want to update the tblApplication.LangID = tlkpLanguage.LangID using the joins described in the select statement?
There is no LangName field in the tblApplication.
I have tried everything and I keep getting syntax errors.
View Replies
ADVERTISEMENT
May 26, 2013
I am working on a hired plant database and want to limit the combo box on the hired form to only list items not on hire.I thought I could do this using the IssueDate and ReturnDate fields within a query with an IIf statement forcing the Yes/No field to choose Yes when there is a date in the IssueDate field and No when the ReturnDate field has a date entered.
View 14 Replies
View Related
Jan 30, 2006
I have four tables with unique records as shown below. I'd like to add a record for a new item to the database by selecting the values from combo boxes for Supplier, Item and Unit. If the values do not exist the user would then type in a new value. SuppliersItemCode and Cost would always be new values. What's the best way to go about this? I am unsure how to add a record to a normalized database where you sometimes have to use / reference existing unique values in multiple tables via foreign keys for the new record.
The logic of the form would be:
1. Select existing or add new Supplier.
2. Select existing or add new Item.
3. Select existing or add new Unit.
4. Enter new SuppliersItemCode
5. Enter Cost
Suppliers
---------
SupplierID (primary key)
Supplier (indexed unique)
Items
------
ItemID (primary)
Item (indexed unique)
Units
-----
UnitID (primary key)
Unit (indexed unique
SuppliersCostsAndCodes
-----------------------
SuppliersItemCostCode (primary key)
Cost
ItemID (foreign key)
UnitID (foreign key)
SupplierID (foreign key)
Any advice or assistance is greatly appreciated, thank you.
View 5 Replies
View Related
Dec 16, 2007
Hello all!
How can I create a query that the select depends on a variable that the user introduces?
would it be something like:
Select [@var] from table ????
it is not working. Example:
@var would be number from 1 to 31 (according to a day on the month that the user wants to view), then the result for it, is the number that the user introduced, instead of the vaule kept in that number...
Hope i make myself clear....
Thanks in advance!
View 14 Replies
View Related
Dec 4, 2005
sql = sql & " WHERE (((tblAccountBalance.DateLastPayment) < #" & reminderdate & "#))"
Im trying to select all the entrys in a table where the date of the last payment is before a variable 'reminderdate' this works fine if both dates are in the same month ie, DateLastPayment = 26/11/05 and reminder date = 30/11/05, but if the DatelastPayment is 26/11/05 and the reminder date is 01/12/05 then nothing is found.
What am I doing wrong?
View 7 Replies
View Related
Sep 16, 2007
I have two tables naming
1.) Criteria and 2.) IndicatorData.
Criteria table has (CriteriaID, CriteriaName,CriteriaValues) Fields. Example( CriteriaName-'Gender 'and values would be 'Male' and 'Female').
IndicatorData table has fields such as (IndicatorDataID, IndicName, Criteria_Code1,Criteria_Value1,Criteria_Code2,Crit eria_Value2,Criteria_Code3,Criteria_Value3).
I made the relationship between the IndicatorData and the Criteria as 1 to many where Criteria_Code1,Criteria_Code2 and Criteria_Code3 ...... up to Criteria_Code5 fields of IndicatorData table reference to the CriteriaID of Criteria table.
I made the sql qury to get all Criteria Names belong to a particular IndicatorDataID but it didnt work. my query is
"SELECT Criteria.tCriteriaName
FROM Criteria INNER JOIN IndicatorData ON (Criteria.nCriteriaId = IndicatorData.CriteriaCode5) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode4) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode3) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode2) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode1)
WHERE (((IndicatorData.nIndicatorId)=9));"
IS IT POSSIBLE TO GIVE THE RELATIONSHIP BETWEEN INDICATORDATA TABLE AND CRITERIA TABLE LIKE THAT OR DOES MY SQL QUERY HAVE SOMETHING TO DO WITH IT...?
answer would be greatly appriciated.
Thanx + Regards
Kosala
View 1 Replies
View Related
Sep 16, 2007
I have two tables naming
1.) Criteria and 2.) IndicatorData.
Criteria table has (CriteriaID, CriteriaName,CriteriaValues) Fields.
Example( CriteriaName-'Gender 'and values would be 'Male' and 'Female' and CriteriaName-'AgeGroup1' and Values-'<30','30-40','40-50','+50').
IndicatorData table has fields such as (IndicatorDataID, IndicName, Criteria_Code1,Criteria_Value1,Criteria_Code2,Crit eria_Value2,Criteria_Code3,Criteria_Value3, IndicValue).
Example-(IndicatorDataID-'ind001', IndicName='No. of participants', Criteria_Code1-'Gender',Criteria_Value1-'Male' and IndicValue-200.)
I made the relationship between the IndicatorData and the Criteria as 1 to many where Criteria_Code1,Criteria_Code2 and Criteria_Code3 ...... up to Criteria_Code5 fields of IndicatorData table reference to the CriteriaID of Criteria table.
I made the sql qury to get all Criteria Names belong to a particular IndicatorDataID but it didnt work. my query is
"SELECT Criteria.tCriteriaName
FROM Criteria INNER JOIN IndicatorData ON (Criteria.nCriteriaId = IndicatorData.CriteriaCode5) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode4) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode3) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode2) AND (Criteria.nCriteriaId = IndicatorData.CriteriaCode1)
WHERE (((IndicatorData.nIndicatorId)=9));"
IS IT POSSIBLE TO GIVE THE RELATIONSHIP BETWEEN INDICATORDATA TABLE AND CRITERIA TABLE LIKE THAT OR DOES MY SQL QUERY HAVE SOMETHING TO DO WITH IT...?
answer would be greatly appriciated.
Thanx + Regards
Kosala
View 1 Replies
View Related
Nov 8, 2014
I have a select clause, it executes fine, BUT the totamt is not calculated. The field is Amount. The code is not working.
strSQL = "SELECT Account, Dept, " & "Sum([Amount])" & " As [totamt] FROM TB201410 GROUP BY Account, Dept;"
View 5 Replies
View Related
Aug 22, 2014
I am attempting to filter records using a multi-select listbox, but all records are being returned. Here is my code.
Private Sub btnKeyboxCount_Click()
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
[Code] ....
View 1 Replies
View Related
Oct 11, 2006
Hi,
I used a before Update procedure to check if the date of a textbox is later than another text box. However, nothing seem to happen when I enter the wrong date.
Here is my code:
Private Sub txtDateOfCompletionForHandover_BeforeUpdate(Cancel As Integer)
Dim anticipatedCompletionDate As Date
Dim dateCompletionHandover As Date
'assign vars values
anticipatedCompletionDate = txtAnticipatedCompletionDate.Value
dateCompletionHandover = txtDateOfCompletionForHandover.Value
'If date1 refers to a later point in time than date2, the DateDiff function returns a negative number
If DateDiff("d", anticipatedCompletionDate, dateCompletionHandover) < 0 Then
MsgBox "You are trying to Handover house before the house is finished!" & vbCrLf & vbLf & _
"Please enter a later date than Anicipated Completion Date above.", , "House Handover"
'empty textbox and keep focus
txtDateOfCompletionForHandover.Text = ""
txtDateOfCompletionForHandover.SetFocus
End If
End Sub
Any help will be very much appreciated.
B
View 10 Replies
View Related
Aug 2, 2005
Hi all,
I'm sure this is easy to do but for some reason i just cannot get it working. Hopefully someone here can tell me where i'm going wrong.
I have two tables in a database and the have a linking unique field. I want to update a column in one table from a column in another where the linking ID field matches.
Here's what i have at present.
Update Table_1 inner join Table_2 On Table_1.ID = Table_2.ID
Set Table_1.[CHI Number] = [Table_2]![CHI_No]
This is just returning the CHI Number column as blanks instead of what i expected would be the same as Chi_No.
Can anyone shed some light on this for me?
Thanks in advance
View 2 Replies
View Related
Dec 10, 2005
Hi all,
I'm trying to use an update query, but somehow, it doesn't store anything in my database. This is my code:
sql = "UPDATE CONSTRUCTIEF SET ConstructiefScore = " & strGebouwConsScore & " AND ConstructiefCommentaar = '" & strGebouwConsOmschrijving & "' WHERE ConstructiefID = " & strGebouwCons
DoCmd.RunSQL sql
When the execution reaches this peace of code, I actually get the right warning message because he's going to update a table, but when i'm looking in the table afterwards, nothing has been updated.
Anybody got any clue?
Thnx in advance,
Freak
View 2 Replies
View Related
Jan 12, 2006
Hello all,
I have the below update query running
UPDATE tbl_master SET tbl_master.COLLRAW =
Iif(tbl_master.PSTATE = "WV","WV",
Iif(tbl_master.PSTATE = "MA","MA",
Null))
WHERE tbl_master.EXCLUDEREASON Is Null
but when I add this line:
UPDATE tbl_master SET tbl_master.COLLRAW =
Iif(tbl_master.PSTATE = "WV","WV",
Iif(tbl_master.PSTATE = "MA","MA",
Iif(tbl_master,MSPBANK in ("751","752","753","854","855"),"GS",
Null)))
WHERE tbl_master.EXCLUDEREASON Is Null
It give me an error message that says "Wrong number of arguments in Query Expression." Can anyone tell me what is wrong with the query above?
Thanks in advance,
Vassago
View 2 Replies
View Related
Apr 24, 2007
Hi Everyone,
Here's the situation:-
I have a patient record with a specific consultant assigned to the patient. In some instances, the patient may request a different consultant. What I want to do is to allow the user to change the consultant and to save details about the change e.g. file no, old value, new value, date etc.
This is what I have done so far:-
I created a Query to retrieve details from 3 tables and assigned the value to be changed to a variable (oldvalue)
I then allow the user to select from a combo box the new consultant.
Details of these changes are then written to a table called tblchanges.
All the above is working.
The problem occurs when I try to update the consultant table, by replacing the old consultant with the newly selected consultant.
Can someone look at the code and let me know first if I am approaching this problem correctly and then why the code is not working.
Private Sub Combo36_Change()
Dim flno As String
Dim fldnme As String
Dim oldval As String
Dim newval As String
Dim tdate As Date
Dim ttime As Date
Dim sqn As String
Dim yrn As String
flno = PFILENO
fldnme = "Radiation Oncologst"
oldval = Text29
newval = Combo36
tdate = Date
ttime = Time
'Insert change values into tblchanges
strSql = "INSERT INTO tblchanges " _
& "( fileno,fieldname, oldvalue, newvalue, datechg,timechg ) " _
& "VALUES ('" & flno & "','" & fldnme & "','" & oldval & "','" & newval & "',#" & tdate & "#,'" & ttime & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
strFILENO = (Left(Me!PFILENO, 4) & "/" & Right(Me!PFILENO, 4))
'update consultant table with new value
stsql2 = "UPDATE tblatdocts SET roncologist = '" & newval & "' "
stsql2 = stsql2 & "WHERE tblatdocts.FILENO = '" & strFILENO & "' "
DoCmd.SetWarnings False
DoCmd.RunSQL stsql2
DoCmd.SetWarnings True
End Sub
Thanks so much for your help.
Will
View 1 Replies
View Related
May 19, 2005
Hi guys,
I have a text field in a database.
I run an update query and the database updates when the form field is text e.g 'location' or numerical '1234'. However if it is mixed, e,g VV1234 it fails to update and i get an update error.
Is this an Access thing? Is there a work around?
Thanks
ronan
View 1 Replies
View Related
Sep 6, 2007
Hello,
I am having a problem w/ my UPDATE statement when the date value is included in the statement. I have tried surrounding the date variable (strDate) in "#" and w/ and w/out single quotes to no avail. I doesn't matter if I dimension strDate as a string or a date. I know there must be a simple solution. In short, the UPDATE statement looks like this:
strSQL = "UPDATE tblTasks SET POC = '" & strPOC & "', Date = #" & strDate & "#, Task = '" & strTask & "' WHERE id = " & lID & ";"
If I remove Date = #" & strDate & "#, then the query works.
These also fail:
Date = #'" & strDate & "'#,
Date = '#" & strDate & "#',
Date = '" & strDate & "',
Any help would be greatly appreciated. Thanks.
Ken
View 3 Replies
View Related
Sep 6, 2007
Hello,
I am having a problem w/ my UPDATE statement when the date value is included in the statement. I have tried surrounding the date variable (strDate) in "#" and w/ and w/out single quotes to no avail. I doesn't matter if I dimension strDate as a string or a date. I know there must be a simple solution. In short, the UPDATE statement looks like this:
strSQL = "UPDATE tblTasks SET POC = '" & strPOC & "', Date = #" & strDate & "#, Task = '" & strTask & "' WHERE id = " & lID & ";"
If I remove Date = #" & strDate & "#, then the query works.
These also fail:
Date = #'" & strDate & "'#,
Date = '#" & strDate & "#',
Date = '" & strDate & "',
Any help would be greatly appreciated. Thanks.
Ken
View 2 Replies
View Related
Sep 23, 2007
hi guys,
i have this sql that filters 2 tables to give me the highest number against a record and then i want to update the 1st table. but it dosnt seam to work it brings back the correct data but the sql has generated a non-updatable query.
any ideas?
UPDATE [SELECT ARCtblErrorInfo.Uber, Max(ARCtblHistory.Status) AS MaxOfStatus
FROM ARCtblErrorInfo LEFT JOIN ARCtblHistory ON ARCtblErrorInfo.Uber = ARCtblHistory.Uber
WHERE (((ARCtblErrorInfo.Status)=121))
GROUP BY ARCtblErrorInfo.Uber]. AS test INNER JOIN ARCtblErrorInfo ON test.Uber = ARCtblErrorInfo.Uber SET ARCtblErrorInfo.Status = [test].[MaxOfStatus];
View 1 Replies
View Related
Mar 23, 2007
I am using an update query comparing 2 tables to add new records from table 2 to table 1. This worked fine until we upgraded to Office 2007. Is this a function of 2007?
I am not getting any prompts to OK, "You are about to update 1500 records"
Thanks for any help.
-Marcus
View 1 Replies
View Related
Jun 26, 2014
I have this update query that is triggered by an after update event on a main form. The record being updated are in a continuous subform. It works well except from the last added/modified record. If I save and close the form and then open it again it works for all records but if modify or add a record, the update query will not work for that last modified/added record.
I have tried several things such as save record, use dirty = false for the on exit event of the subform control but nothing works. Here is the procedure:
Code:
Private Sub cboPoCurrency_AfterUpdate()
On Error GoTo ErrHandler
Dim db As Database
Dim strSql As String
Dim lngID As Long
Dim dblRate As Double
Set db = CurrentDb
[Code] ....
View 14 Replies
View Related
Dec 16, 2013
I am trying to update values in an unbound text box based on a selection in the combo box on the same form; however whilst I am easily able to display the information for the first selection the values do not update when I change the value in the drop down.
View 7 Replies
View Related
Oct 29, 2013
I've done this tons of times, so I don't understand what's happening... The title says it all: when I update the ID of one record of the main table, the referenced records on related tables won't update even though they have a relationship between them with the option "Cascade update" clicked.
In the attached database, the main table "Expedientes" is related to table "Actuaciones".
View 1 Replies
View Related
Nov 2, 2006
Hi,
I have a database with a couple of tables. The primary table has a primary key called "StaffNo". I checked the relationships between the primary table and each related table, if I have ticked on the boxes for referential integrity, cascade updates. All done. If I now create a query, which selects the primary table and one related table and enter a new StaffNo, I would expect to see the new StaffNo not only in the primary table but also in the related one. But there is nothing. Do I expect wrong? Have I missed sth.? I read a few posts in this and other forums reg. referential integrity, but I have no clue, what's wrong. :confused:
Any quick help is much appreciated.
Thanks :)
View 1 Replies
View Related
Oct 4, 2013
What I'm trying to do here is, update my access table ("Table1") from excel sheet ("Myexcel.xls"). Excel file contains all the information however access table is not updated except "RefNo" field. Condition what I coded here is when once connection is build, "RefNo" in excel matched with "RefNo" of access table , update the other fields in Access table. Which is working fine (doesn't showing any error) but still data is not updated in access table. I don't know why is not updating it....
Private Sub Command0_Click()
Dim accessCMD As ADODB.Command
Dim accessRS As ADODB.Recordset
Dim accessParam As ADODB.Parameter
Dim bFound As Boolean
[code]....
View 3 Replies
View Related
Jun 27, 2014
Why update query isn't working when trying to update an multivalued field. In this table, there are 647 records and only 9 of which already have a value set in the "AssociatedProject" field. More than one AssociatedProject is associated with a vendor, so this field allows for multiple entries. I've looked at all the information on update queries and updating a multivalued field, but it will only update the existing 9 records. It does not recognize the remaining ones (they have no values yet).
Here's the SQL:
UPDATE Tbl_Vendor SET Tbl_Vendor.AssociatedProject.[Value] = 3
WHERE (((Tbl_Vendor.AssociatedProject.Value) Is Null));
View 9 Replies
View Related
Feb 27, 2006
I have 2 tables with the following fields.
OrderInfo
PO Number
Status
CustomerInfo
Purchase Order Number
Customer Name
Customer Phone
Order Status
This is what I am trying to do:
get the Status for a the PO Numbers from the first table and update the Order Status field for those same PO Numbers in the second table.
This is how I am doing it currently:
I created a select query and saved it as ExistingPO. This is what ExistingPO looks like.
SELECT OrderInfo.*
FROM CustomerInfo INNER JOIN OrderInfo ON CustomerInfo.[Purchase Order Number] = OrderInfo.[PO Number];
and then I created another query which makes use of this first select query. The second query looks like this
UPDATE CustomerInfo INNER JOIN ExistingPO ON CustomerInfo.[Purchase Order Number] = ExistingPO.[PO Number] SET CustomerInfo.[Order Status] = ExistingPO.Status;
But I was wondering is there was a way to combine the first query and the second query into one query?
View 1 Replies
View Related