I have an MS Access 2003 front-end (queries, forms, reports) connected to a SQL server back-end database (SQL Server 2000).
When I try to run an append query against any of my SQL tables with a unique identifier, I get the error...
"Explicit value must be specified for Identity Column it table 'table1' when IDENTITY_INSERT is set to ON (#545)"
I am trying to create a duplicate record process for my users, by appending data using append queries to the same table. I used the MS Access built in wizard to duplicate the main record on the form, but was going to have to use append query code to duplicate the sub-form records.
Is there anyway around this error, or am I stuck as far as writing code to run this append query on the fly?
I am running a query that keeps asking for me to enter data for some fields before it opens the query, which I don't. When the query opens, the data in the fields is there.? Why? This is what is written in the field (query):
Total Jumbos: nz([pathjbo50],0)+nz([esjbo50],0)+nz([f1jbo50],0)
The quote "Total Jumbos:" is my label. The rest is my expression. This setup works on a few other columns I entered but this one (and a few others) don't. Any suggestions would be appreciated.
FYI: The query information is gathered from a table populated by a form. The label "Total Jumbos" is not on the original table but I have other labels in the same query that are also not on the original table that do work.
I am modifying some queries in a DB which is only 411,000 KB. It still has plenty of room left before reaching 2GB. When I go through and test the queries, some run fine with no issues.Then I get to one of the last queries and get this error: "The query cannot be completed. Either the size of the query result is larger than the maximum size of a database (2 GB), or there is not enough temporary storage on the disk to store the query itself."
I still have about 1.5 GB of RAM available when this query is running, so it doesn't appear to be a RAM issue, and the DB still has plenty of room left to store the result set of this query.
I am wanting to run a query in my FE which takes data from a Linked DB and copies this to my BE for general user access. The query itself contains three tables with the final table being a Left Outer Join.
If I run this query to append to a table in my FE it runs fine. If I run it to append to the exact same table copied to the BE I get the error "Record is Deleted". If I then open the table there is nothing showing in it. If I then run a delete query on the table it find records to delete.
After some investigation I have discovered this happens whenever there is null data on the Left Outer Join table.
Does anyone know why this works fine appending to the FE but not the BE and more importantly how to resolve or work round this problem.
I have created an append query to begin the transfer of terminated employees to a separate table then delete them from the Active file using a Macro. I get an error running the append query and I have attached the error to this thread. I answer all the halts in the affirmative and the process does happen the way I want it to. The terminated employees get added to the Terminated table and they delete from the Active table. I don't understand what the error is telling me and why its doing the job anyway. Thanks for looking.
INSERT INTO tblEmployeesTerminated ( EmpID, LastName, FirstName, Status, [Position], EmpDate, TermDate, LastChgDate ) SELECT tblEmployeeRecord.EmpID, tblEmployeeRecord.LastName, tblEmployeeRecord.FirstName, tblEmployeeRecord.Status, tblEmployeeRecord.Position, tblEmployeeRecord.EmpDate, tblEmployeeRecord.TermDate, tblEmployeeRecord.LastChgDate FROM tblEmployeeRecord WHERE (((tblEmployeeRecord.Status)="Terminated") AND ((tblEmployeeRecord.TermDate) Is Not Null));
SELECT SubscheduleID, EventID, WeekOrder, DayID, StartTime, EndTime, Priority, CanJoin, PatientTitle, PatientNickname, IncludesPatient, IncludesAftercare, Letter1 FROM [qryScheduleCombinedDetails] WHERE (SubscheduleID = 1 AND IncludesPatient = -1 AND DuringAftercare <> "AC only" AND (WeekOrder = "All" OR WeekOrder = 3 OR (WeekOrder = 1 AND Letter1 = "XYZ")) AND DayID = 2 AND StartTime <= #8:00:00 AM# AND EndTime >= #8:30:00 AM#);
When I try to run it, I get a "data type mismatch" error. When I put the same code into a query, I get the same error. However, it will run if I delete either condition from within the (WeekOrder = 1 AND Letter1 = "XYZ") pairing. I can't figure why it can run with either of those, but not both together.
WeekOrder is defined as String. Letter1 is calculated as Cstr(Nz(IIf(Letter,"XYZ","ABC"))) within [qryScheduleCombinedDetails], because I wanted to make sure that it would be recognized as a string.
I've encountered another weird error when applying an append query through a button. Here's the code:
Private Sub cmdSaveChanges_Click()
On Error GoTo Err_cmdSaveChanges_Click 'Saves the new Inspector information into the information table. 'Adds the two references created by adding a new inspector into the XREF_FILE_INSPECTOR table. 'This is the case that the references are formed by adding a completely new inspector. If (IsNull(cmbInspector) Or Me.cmbInspector = "") Then
Else 'This is the case where the user chooses an inspector from the provided combo box. DoCmd.RunSQL "INSERT INTO XREF_FILE_INSPECTOR " _ & "(FILE_NUMBER_CD, INSPECTOR_NUMBER_CD) VALUES " _ & "(" & [Forms]![GeneralFile].[txtGeneralFileNumber] & "," & cmbInspector.Column(0) & " );" End If Exit_cmdSaveChanges_Click: Exit Sub
Err_cmdSaveChanges_Click: MsgBox Err.Description Resume Exit_cmdSaveChanges_Click End Sub
The problem is, when I run this I get a "Syntax error in INSERT INTO statement". This seems to only be the case for the first part of the IF statement, as the second part's append query works fine.
I am having problems adding details from StudentForm to student table. When I click on the add student button it throws back an error Microsoft Access cant append all the records in the append query.I have attached the error as a pdf and the database for info.
I have a query that uses the input from a form as criteria, which is then used in a report. The form input is a drop down based on another table. This is a sales pipeline report, and the list is a list of sales people. The report works perfect for all sales people except one. When I run it for the one, I get the following error:
"This expression is is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables".
I DO NOT get the same error when running the query by itself - so assuming there is something in the report causing this. I do have some sum formulas in the report.
Again, no other salespersons selected cause this error -- so I am assuming there is something in the dataset for this person that is causing the error.
Hi, I get this error when trying to rung a piece of code: The expression On Load you entered as the event property setting produced the following error: Member already exists in an object module from which this object module derives.
I have the EXACT same code working on other forms using different fields and I just can't figure out why this particular one isn't working, it's driving me nuts! My code is this: Private Sub Form_Load() Dim strReason As String
strReason2 = Nz(Ref3Poor_Reason, " ")
Select Case strReason3 Case "Not Known", "Unwilling to Give" Poor1NavRef3.Visible = False Poor2NavRef3.Visible = True
Case Else Poor2NavRef3.Visible = False Poor1NavRef3.Visible = True
End Select
Dim Ref3PoorCheck As Boolean Ref3PoorCheck = Ref3Poor_Reference
Select Case Ref3PoorCheck
Case "True" Ref3Poor_Reason.Visible = True
Case "False" Ref3Poor_Reason.Visible = False
End Select
End Sub
Can anybody tell me where I'm going wrong please? Thanks, Dan
I get a syntax error when I run this query from an Access Module but I don't get an error when I run it as a straight query. Can anyone see what's wrong with it? I am using Access 2003
Dim sqlStmt As String
sqlStmt = "SELECT [CCC Companies].ESTBLMT_NO, SUM(subWeight) AS weight " sqlStmt = sqlStmt + "FROM [CCC Companies], [SELECT ESTBLMT_NO, COUNT(*) * 10 AS subWeight " sqlStmt = sqlStmt + "FROM CCCWords " sqlStmt = sqlStmt + "WHERE Word IN ( Select word from CBCWords where vendor = '" sqlStmt = sqlStmt + strVendor sqlStmt = sqlStmt + "') GROUP BY ESTBLMT_NO " sqlStmt = sqlStmt + "UNION " sqlStmt = sqlStmt + "SELECT ESTBLMT_NO,COUNT(*) * 25 AS subWeight " sqlStmt = sqlStmt + "FROM CCCCleansedPhone " sqlStmt = sqlStmt + "WHERE MID(STRIPPED_PHONE,1, 5) IN ( Select MID(STRIPPED_PHONE,1 ,5) FROM CBCCleansedPhone WHERE vendor_no = '" sqlStmt = sqlStmt + strVendor sqlStmt = sqlStmt + "') GROUP BY ESTBLMT_NO " sqlStmt = sqlStmt + "UNION " sqlStmt = sqlStmt + "SELECT ESTBLMT_NO, COUNT(*) * 50 AS subWeight " sqlStmt = sqlStmt + "FROM CCCCleansedPhone " sqlStmt = sqlStmt + "WHERE MID(STRIPPED_PHONE,1, 7) IN ( Select MID(STRIPPED_PHONE,1 ,7) FROM CBCCleansedPhone WHERE vendor_no = '" sqlStmt = sqlStmt + strVendor sqlStmt = sqlStmt + "') GROUP BY ESTBLMT_NO " sqlStmt = sqlStmt + "UNION " sqlStmt = sqlStmt + "SELECT ESTBLMT_NO, COUNT(*) * 50 AS subWeight " sqlStmt = sqlStmt + "FROM CCCCleansedPostalCode " sqlStmt = sqlStmt + "WHERE MID(STRIPPED_POSTAL,1, 6) IN ( Select MID(STRIPPED_POSTAL,1 ,6) FROM CBCCleansedPostalCode WHERE vendor_no = '" sqlStmt = sqlStmt + strVendor sqlStmt = sqlStmt + "') GROUP BY ESTBLMT_NO " sqlStmt = sqlStmt + "]. AS dupWeight " sqlStmt = sqlStmt + "WHERE dupWeight.ESTBLMT_NO = [CCC Companies].ESTBLMT_NO " sqlStmt = sqlStmt + "GROUP BY [CCC Companies].ESTBLMT_NO " sqlStmt = sqlStmt + "HAVING SUM(subWeight) >= 60 " sqlStmt = sqlStmt + "ORDER BY SUM(subWeight) DESC"
DoCmd.OpenForm "Show Probabilities", , , sqlStmt
Here is the code that runs ok in a straight query:
SELECT [CCC Companies].ESTBLMT_NO, SUM(subWeight) AS weight FROM [CCC Companies], [SELECT ESTBLMT_NO, COUNT(*) * 10 AS subWeight FROM CCCWords WHERE Word IN ( Select word from CBCWords where vendor = '100024') GROUP BY ESTBLMT_NO UNION SELECT ESTBLMT_NO, COUNT(*) * 25 AS subWeight FROM CCCCleansedPhone WHERE MID(STRIPPED_PHONE,1, 5) IN ( Select MID(STRIPPED_PHONE,1 ,5) FROM CBCCleansedPhone WHERE vendor_no = '100024') GROUP BY ESTBLMT_NO UNION SELECT ESTBLMT_NO, COUNT(*) * 50 AS subWeight FROM CCCCleansedPhone WHERE MID(STRIPPED_PHONE,1, 7) IN ( Select MID(STRIPPED_PHONE,1 ,7) FROM CBCCleansedPhone WHERE vendor_no = '100024') GROUP BY ESTBLMT_NO UNION SELECT ESTBLMT_NO, COUNT(*) * 50 AS subWeight FROM CCCCleansedPostalCode WHERE MID(STRIPPED_POSTAL,1, 6) IN ( Select MID(STRIPPED_POSTAL,1 ,6) FROM CBCCleansedPostalCode WHERE vendor_no = '100024') GROUP BY ESTBLMT_NO ]. AS dupWeight WHERE dupWeight.ESTBLMT_NO=[CCC Companies].ESTBLMT_NO GROUP BY [CCC Companies].ESTBLMT_NO HAVING SUM(subWeight)>=60 ORDER BY SUM(subWeight) DESC;
hi Guys, I have been looking at different post and checking Microsoft help files as well, but still can't seem to fix this problem.
I am having 2 tables. The first table is connected to a form for viewing and entering data, and in the second table i am just copying 3-4 fields from the first table.
I am trying to use the insert statement to insert records in the second table, and everytime i click on the "Add" button to add the records i get the following error "MS access can't append all the records in the append query ... blah blah blah"
However if i close the form and reopen it, and goto the record (as it is saved in the first database) and now click on the add button to add the fields to the second table/database, it works.
The problem is lately; while testing I am running multiple queries in a routine. When it fails; its hard to identify which query has the problem. So I hit control break; debug and try to find it. After I fix it; I debug and reset; i get this continuing hourglass thing in the form of a spinning circle until I close and reopen the database. I think I need better error handling but not something really complicated because I need to put it in quite a few routines throughout the database.
Hello, I have an append query attached to a text box called client on a form, and every time I enter data into this text box and click the next text box last name I get this error from microsoft office Access that says (You are about to append 0 rows) (Are you sure you want to append selected rows?) I click yes and every thing to work fine. I just wish this error message would go away.
I'm using Access 2003.
Thanks--Any Suggestions would be very appreciated.
Wow, this thing is annoying me. I give up! I've attached the database for anyone here to have a look at. I promise there's no nasty code on it, although you should be able to see my code and hopefully pick the problem if you disable macros anyway.
I use VBA to prompt users to enter their staff number, the member's number and the book ID. The same VBA checks to make sure that it's a valid number that they're entering, that's it's actually present in the table it's being referenced from. (Command0 button. Command1 is to return an item)
It then takes these values, the current date and another date variable and inserts into the LOAN table. The loan table has enforced referential relationships with the book, member and staff tables.
All the fields in Loan (except for the autonumber PK) are not required, and have no validation formulas, zero-length is permitted where applicable.
I KNOW that the numbers being inserted are in the related tables! They're the same data type - long integers, and the related tables' primary keys are not autonumbers.
So why am I still getting a key constraint violation??
Can someone please help me??
Correction: I'm trying to attach the database, but it's too big, even zipped. Why isn't RAR accepted? Anyway, the file is hosted here: http://jellopy.com/files/newdb.zip
I'm trying to write a code so that it gets the data from a query (QryPrint) and then to put them in a temporary table (tblWeekData) so that I can present them in a report.
I have written the following code but the vba gives error constantly on DietID which is a field (into query).
Sub OpenReport() Dim i As Integer, x As Integer, tmpMax As Integer, TheFood As String Dim rsSource As DAO.Recordset Dim rsTarget As DAO.Recordset CurrentDb.Execute "DELETE * FROM tblWeekPlan" Set rsTarget = CurrentDb.OpenRecordset("tblWeekPlan", dbOpenDynaset)
Hi, when I run a simple append query, I get the following message below (See attached) I tried the solution in microsofts website that I have to set all text fields to AllowZeroLength to Yes, and i did that in both the table the data comes from, and the table the data is appended to. Still cant get it to work? Any other suggestions or is there somthign simple that im missing?
Can anyone tell me how to get a running balance on a report. I know how to create a running total, by setting the "running sum" property of a text box to "Over all".
I can't however see how I can adapt this to give a running balance (as in a bank statement for example). Attempts to do so end up in failure!!
Sorry I am to bother you. But I was wondering whether it is possible to create a running sum in a query (from each previous record just a simple add up)?
I know how to do in report (it is described in the help function) but for a query I cannot find anything.
I have another table, Transaction, that's based off the Loan Number field on the loans table.
Fields: LoanNumber Payment Type (2 choices, payment and advance) Amount
I have a user form where users can specify the payment type, and amount, based on a certain loan number.
I'm attempting to do this:
User enters a transaction into the database. once the transaction is entered, the Principal Balance field for the specified loan number is updated.
If the payment type is advance, the query will subtract the amount from principalbalnce. if payment, the query wll add the amount to the principal balance.
Here's what I have so far.
The userform updates the transactions table with the information correctly.
My next step is to update the principal balance.
I'm thinking I could use some sort of update query, but I don't know where to begin.
HELP!!
If there is a better (normalized) way to accomplish this, I'm definitely open to ideas. Please just provide a basic example so I can understand. :o :cool:
I have a query that shows part numbers with a total qty ordered for a specified time period. This first part of the query is fine and is made into a table.
I am then trying to use this table to create a running sum with the list sorted in descending order, and ultimately break the list where the sum reaches 80% of the total qty across the whole list. I have tried the following formula and the table has been indexed in the descending order it would need to be in. The IndexAlias has also been created and made into a fixed table prior to running the 'Running Sum' query.
I have taken this formula from the microsoft link below, (Method 2), and adapted it to my query. However, although I have a decent understanding of Access I do not understand the '&' in this formula. Removing this and the double quotes on the end returns an error and leaving them in returns zeros all the way down the 'RunTot' field. If anyone can help I would appreciate it as I am stuck on this.