473,549 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot get Append/Update queries to work..Please Help

48 New Member
Morning Everyone...

I have a table that needs to be append to and also updated. All the fields in the table are populated with data from the text boxes and combo boxes on a form. The Date Submitted defaults to 1/1/00 if the cboSubmittedBox field is "No". Otherwise it is selected from a calendar. The Date Entered field defaults to the current date. There are 3 sets of criteria that need to be checked for the update or append to take place.

Table Fields
Title, TitleID, Year Created, Submitted, Submitted To, Website, Type, Accepted, Date Submitted, Date Entered

All are based on one combo box with only two options.

1)
Expand|Select|Wrap|Line Numbers
  1. If  Me![cboSubmittedBox] = "No" Then
  2.                 Dim stAppend As String
  3.                 stAppend = "Created_Submitted_Work"
  4.                 DoCmd.OpenQuery stAppend, acNormal, acEdit
  5.  
This option sets all the fields in the table to "Not Applicable" except the Title, TitleID, Year Created, Date Submitted and Date Entered fields.

2)
Expand|Select|Wrap|Line Numbers
  1. If  Me![cboSubmittedBox] = "Yes" Then
  2.                 HERE IS WHERE ADDITIONAL CODE NEED TO GO
  3.                 BUT I CANNOT GET IT TO WORK.  CODE WILL NOT
  4.                 RECOGNIZE THE TABLE AND FIELDS I USE AND A
  5.                 DLOOKUP ONLY GRABS ONE RECORD.  THE 
  6.                 PROBLEM IS THE SAME FOR THE NEXT EXAMPLE.
  7.                 Dim stAppend As String
  8.                 stAppend = "Created_Submitted_Work"
  9.                 DoCmd.OpenQuery stAppend, acNormal, acEdit

3)
Expand|Select|Wrap|Line Numbers
  1. If  Me![cboSubmittedBox] = "Yes" Then
  2.                 HERE IS WHERE ADDITIONAL CODE NEED TO GO
  3.                 BUT I CANNOT GET IT TO WORK.  CODE WILL NOT
  4.                 RECOGNIZE THE TABLE AND FIELDS I USE AND A
  5.                 DLOOKUP ONLY GRABS ONE RECORD.  THE 
  6.                 PROBLEM IS THE SAME FOR THE PREVIOUS EXAMPLE. 
  7.                 Dim stAppend As String
  8.                 stAppend = "Created_Submitted_Update_Query"
  9.                 DoCmd.OpenQuery stAppend, acNormal, acEdit

What I need to do is have examples 2 and 3 query the table to the words "Not Applicable" in the any of the fields that contain that text, for example the website field. If the website field does not contain "Not Applicable" then the append query will run. If it does contain "Not Applicable" then the update query will run.

I cannot get the VB code to recognize the table "Created_Submit ted" and the field "Website". It would be coded as [Created_Submitt ed.Website] in an if statement such as If [Created_Submitt ed.Website] = "Not Applicable" Then...

Doing that doesn't work though. It just doesn't even run the append or update queries.

I have been fighting this off and on for a couple of weeks and am at my wits end. Any help you all could give would be greatly appreciated.
Jun 10 '08 #1
4 2395
missinglinq
3,532 Recognized Expert Specialist
Your duplicate posting of this question/problem has been deleted! Please refrain from this prohibited behavior in the future.

From FAQs

Do Not Double Post Your Questions

Double posting is where you start a thread on a topic and then for some reason start another thread on exactly the same topic in the same forum. Please do not do this because

  • It makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.
  • It swamps the forum with your problem resulting in less attention for the other threads.
If you feel for some reason that you post has been overlooked (if, for instance, it hasn't had any replies) please do not repost the question. Post a message to the thread you started, this will bump it back to the top of the thread list for the forum.

Thank you for your attention in this matter.

Linq ;0)>
Jun 11 '08 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Doug, it seems that this can be (and probably should have been) broken down into a requirement to update / append depending on the existing contents of the data.

It's all very difficult to understand as there is so much that's misleading and items in the code that are misnamed, but if I understand you correctly you have to append the special (Not Applicable) records when the cboSubmittedBox is set to "No", but when it's set to "Yes" we need to Append/Update depending on the current data.

I won't ask why the "Yes"/"No" control is a ComboBox rather than a CheckBox. I assume you have some reason that is not relevant to this question (Even if not then it's not a problem - simply more complicated than necessary). I just thought it may help to bring this to your attention.

I suppose I should next state that there is no facility in SQL to "Add or Update". A fairly frequent requirement is to do this depending on whether or not the PK of the record is matched. I can't tell what your PK is in this case so giving any definitive answer will be impossible. Unfortunately, this facility isn't available anyway, so we will need code to support the following logic :
If [cboSubmittedBox]="No" then Append anyway, with some fields set to "Not Applicable".
Expand|Select|Wrap|Line Numbers
  1. Otherwise:
  2.     If a record is found that matches the [TitleID] and has "Not Applicable" in ANY of the five fields (just check one) then update this record
  3.     Otherwise:
  4.         Add the record as a new one.
Finally, the correct way to reference the item would be [Created_Submitt ed].[Website] rather than [Created_Submitt ed.Website] as you had it.
Jun 11 '08 #3
dougmeece
48 New Member
Sorry about the double post. In the first I had entered the word "Thanks" at the end of the subject and I thought that might lead people to think that I had my answer and was thanking people for the help.

NeoPa,

I am so far removed from VB and Access that I am basically starting over. I am sure I have many things wrong in my code and I appreciate any and all critiques.

I have tried entering the code the way you described but it didn't work either. I worked around the problem but I know it isn't very efficient. I just gave each option its own command button and coded to make it work. I know that is sloppy but it was all I could get to work.

Thanks for the help.
Jun 12 '08 #4
NeoPa
32,564 Recognized Expert Moderator MVP
I hear you Doug, and I sympathise.

I would just make a comment though that will hopefully provide some guidance.
It is generally better in the long run, to organise the process (in your head or on paper) at the start. This will save a deal of grief later on. Understanding the requirement and the process clearly makes coding it so much easier and straightforward .

As for your attempts at getting the logic to work, if you have any specific questions we can help with I'd be glad to see what I can do.
Jun 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5774
by: JMCN | last post by:
hi i need some advice on whether if it would be better to use an append query or an update query. here is the situation, i have linked another database table to my current database. then i created a query for the linked database but eventually i need to have this query to be constantly updated and append to another table in the current...
1
3403
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria"
6
2478
by: dd_bdlm | last post by:
Hi all I have a database that stores customer records and their associated insurance details. I need to be able to archive any changes made to that record. Currently the user selects 'record change' whenever anything is changed in the details. So I have created an append query for the appropriate tables and stored the details in a new...
13
4210
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a solution here - until now. This one is driving me crazy. I am making my first attempt at creating a runtime application. I am using Access 2003...
6
2197
by: Robin Lawrie | last post by:
Hi, Looking for some help here! I'm adding records to a SQL 2000 DB using the objRS.AddNew and objRS.Update methods. What I'd like to do is determine the new primary key value of the added record.
4
7373
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the imported text file. I can update the data through an update query or append the entire import table through an append query. Is there a way to combine...
3
8050
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we incur numerous service problems “Events”. Each morning we have a global conference call where events which occurred within the previous 24 hours are...
3
1914
by: bazdaa | last post by:
Access 2K3 Append/Update ignore non null cells! Hi, I have been tasked with completing an audit of approximately 10,000 items, to which I have generated a list of 40 questions (fields) for each record. I began collating the information in Excel, but found myself getting lost and even experienced major data loss on at least 2 occasions. I...
14
4607
by: Rich P | last post by:
Hi Sara, If you try it this way - you may have better luck Dim strSql As String strSql = "INSERT INTO tblPOCancels ( PONum, PODate, DateEntered, MerchantKey,VendorKey, POApproved, " _ & "SuggShipDate, Description, CostofGoods, Freight, TotalRetail,
0
7532
marktang
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...
0
7462
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...
0
7730
Oralloy
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. ...
0
7975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7492
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6059
agi2029
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...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1957
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.