473,605 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with an update query

30 New Member
I have a form that has two subforms on it - one of them is continuous and lists a bunch of data about a given service's performance measures, while the other is a single view form where the user selects a measure from a combo box (cbo_Measure). After a measure is selected, the other text boxes in the form are updated with relevant information from the database. I am trying to set it up so that after the user updates the action plan for that measure, the form checks to see if the ActionPlan textbox is empty; if it is empty, I want to update the "ActionPlanComp leted" field to "No," and if there is text in there I want to update it to "Yes." I then requery the other subform to display the change.

Here is the code I have so far -

Private Sub ActionPlan_Afte rUpdate()
Dim strSQL As String
Dim strCriteria As String

strCriteria = ""
If Me!ActionPlan.V alue = "" Then
strCriteria = "Yes"
Else
strCriteria = "No"
End If

MsgBox (Me!cbo_Measure )
MsgBox (Me![cbo_Measure])
MsgBox (Service_ID)
MsgBox (strCriteria)
strSQL = "UPDATE tbl_Service_PM " & " SET tbl_Service_PM. ActionPlanCompl ete = " & strCriteria & " WHERE tbl_Service_PM. Service_ID = " & Service_ID & " AND tbl_Service_PM. Measure = " & Me![cbo_Measure]
MsgBox (strSQL)
DoCmd.RunSQL strSQL
Forms![frm_Performance Measure]![sfrm_Service_PM].Requery
End Sub

All of the message boxes are popping up with the correct values in them, except for strCriteria. That shows up as "No" whether the text box is blank or not. I am having three other problems with this -

1. tbl_Service_PM. ActionPlanCompl ete is not getting updated at all, though I get a message saying that 1 row has been updated.
2. When it runs, it always prompts me for a value of cbo_Measure. For instance, if the value in the combo box is MC3, a prompt pops up for me to give a value for MC3. If I type in anything except for MC3, the message saying how many rows were updated gives me a 0.
3. After the update, the next time I bring the focus to the other subform, I get a Write Conflict error message.

I've been stuck on this for a few hours already this morning, and it's really starting to stress me out.
Sep 4 '07 #1
9 1746
FishVal
2,653 Recognized Expert Specialist
Hi, Monroeski.

I think you don't need at all to store strCriteria in the table as soon as value of tbl_Service_PM. ActionPlan is the criteria itself.
Simply retrieve it's value with a query like this
Expand|Select|Wrap|Line Numbers
  1. SELECT *, iif(isnull(tbl_Service_PM.ActionPlan), "No", "Yes") AS ActionPlanComplete FROM tbl_Service_PM;
  2.  
Sep 4 '07 #2
Monroeski
30 New Member
Would IsNull even pick that up? A zero-length string isn't the same thing as Null, is it?

::edit::
nm, just tried it, and it returns correctly. Still not updating the table correctly, though.

None of the forms involved actually uses tbl_Service_PM as a record source, they both use queries (which do contain fields from tbl_Service_PM) . Could that be part of the problem? It's really confusing me why it tells me that a record has been updated when I can go into the table and see with my own eyes that it hasn't.
Sep 4 '07 #3
FishVal
2,653 Recognized Expert Specialist
Would IsNull even pick that up? A zero-length string isn't the same thing as Null, is it?

::edit::
nm, just tried it, and it returns correctly. Still not updating the table correctly, though.

None of the forms involved actually uses tbl_Service_PM as a record source, they both use queries (which do contain fields form tbl_Service_PM) . Could that be part of the problem? It's really confusing me why it tells me that a record has been updated when I can go into the table and see with my own eyes that it hasn't.
????
Is tbl_Service_PM. ActionPlan field value not a strict criteria for ActionPlan being completed?
Sep 4 '07 #4
Monroeski
30 New Member
????
Is tbl_Service_PM. ActionPlan field value not a strict criteria for ActionPlan being completed?
Not sure exactly what you're asking. I can say that the only thing that changes ActionPlanCompl eted from yes to no and vice-versa is the ActionPlan text box in this form. It is set up to run the above VBA code AfterUpdate.
Sep 4 '07 #5
FishVal
2,653 Recognized Expert Specialist
Not sure exactly what you're asking. I can say that the only thing that changes ActionPlanCompl eted from yes to no and vice-versa is the ActionPlan text box in this form. It is set up to run the above VBA code AfterUpdate.
I mean the following.

What a reason to have [ActionPlanCompl eted] field in the table as soon as it only indicates whether [ActionPlan] is null or not? Or [ActionPlanCompl eted] value is not so strictly depends on [ActionPlan] value?

The problem is that ActionPlan text box is only supposed to be "the only thing that changes ActionPlanCompl eted from yes to no and vice-versa".
Sep 4 '07 #6
Monroeski
30 New Member
I mean the following.

What a reason to have [ActionPlanCompl eted] field in the table as soon as it only indicates whether [ActionPlan] is null or not? Or [ActionPlanCompl eted] value is not so strictly depends on [ActionPlan] value?

The problem is that ActionPlan text box is only supposed to be "the only thing that changes ActionPlanCompl eted from yes to no and vice-versa".
I think I see what you're asking. The ActionPlanCompl eted field is already in the table beforehand, and every entry is "No." Basically, we'll be rolling this out to the organization with everything blank, then each service inputs their own information. So, the starting value for ActionPlanCompl eted is "No," and it will only change to "Yes" after a representative from the service has gone in and added data. Should they happen to go back in to the ActionPlan and delete the information there, I want ActionPlanCompl eted to reflect that, so I allowed for it to change back to "No" if that field is null.

I'm starting to have issues with the whole way this thing is set up, I may try to figure out a different way ot track this rather than keep trying to make this one work.
Sep 4 '07 #7
FishVal
2,653 Recognized Expert Specialist
I think I see what you're asking. The ActionPlanCompl eted field is already in the table beforehand, and every entry is "No." Basically, we'll be rolling this out to the organization with everything blank, then each service inputs their own information. So, the starting value for ActionPlanCompl eted is "No," and it will only change to "Yes" after a representative from the service has gone in and added data. Should they happen to go back in to the ActionPlan and delete the information there, I want ActionPlanCompl eted to reflect that, so I allowed for it to change back to "No" if that field is null.

I'm starting to have issues with the whole way this thing is set up, I may try to figure out a different way ot track this rather than keep trying to make this one work.
Ok. As you like.
To run the update query you just need to enclose string values assigning to text type fields in single quotation marks .

Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE tbl_Service_PM " & " SET tbl_Service_PM.ActionPlanComplete = '" & strCriteria & "' WHERE tbl_Service_PM.Service_ID = " & Service_ID & " AND tbl_Service_PM.Measure = " & Me![cbo_Measure] & ";"
  2.  
or if tbl_Service_PM. Measure is text type field too, then
Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE tbl_Service_PM " & " SET tbl_Service_PM.ActionPlanComplete = '" & strCriteria & "' WHERE tbl_Service_PM.Service_ID = " & Service_ID & " AND tbl_Service_PM.Measure = '" & Me![cbo_Measure] & "';"
  2.  
Sep 4 '07 #8
Monroeski
30 New Member
Ok. As you like.
To run the update query you just need to enclose string values assigning to text type fields in single quotation marks .

Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE tbl_Service_PM " & " SET tbl_Service_PM.ActionPlanComplete = '" & strCriteria & "' WHERE tbl_Service_PM.Service_ID = " & Service_ID & " AND tbl_Service_PM.Measure = " & Me![cbo_Measure] & ";"
  2.  
or if tbl_Service_PM. Measure is text type field too, then
Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE tbl_Service_PM " & " SET tbl_Service_PM.ActionPlanComplete = '" & strCriteria & "' WHERE tbl_Service_PM.Service_ID = " & Service_ID & " AND tbl_Service_PM.Measure = '" & Me![cbo_Measure] & "';"
  2.  
I actually got the query working (I thought) right before you posted this message, but when I went in to the actual table, instead of just updating the ActionPlanCompl ete field, it also changed another field from 61 to 3997701 or something like that and a couple of other fields from strings to random symbols. ????

At that point I just decided to drop it until tomorrow, when a cooler head should prevail. : )

Thanks for all the help.
Sep 4 '07 #9
FishVal
2,653 Recognized Expert Specialist
I actually got the query working (I thought) right before you posted this message, but when I went in to the actual table, instead of just updating the ActionPlanCompl ete field, it also changed another field from 61 to 3997701 or something like that and a couple of other fields from strings to random symbols. ????

At that point I just decided to drop it until tomorrow, when a cooler head should prevail. : )

Thanks for all the help.
Put
Expand|Select|Wrap|Line Numbers
  1. Debug.Print strSQL
before
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL strSQL
line and see what query actually runs.
Sep 4 '07 #10

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

Similar topics

3
2948
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But not update. Here is a copy of the script I am using. I do not know what version of MySQL my host is running nor do I have Shell Access to it. I
0
2423
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish, Swedish or English). There are about a dozen tables with columns that need localization. Doing this in the application level was a no-goer. It would have taken far too much time (there is a *lot* of code and unfortunately most of the...
11
2094
by: rishi_israni | last post by:
Hi, i am having a strange problem running memory intensive queries on SQL server. I am doing an update on a table with 9 million records from another table with 50 records. the query i am running is
2
5831
by: Joshua Moore-Oliva | last post by:
I have a query that is asking me to GROUP a column, yet when I GROUP it it causes an error near GROUP. What is very strange about the following query is that the line list_size_active = COUNT(NEW.active) PROPERLY sets the value to the number of new items.
2
1855
by: Jonathan \(Pickles\) Sklan-Willis | last post by:
Hi All, This is what I want to do: 1. Build a database in Access with certain queries and a query form. (DONE). 2. I now need to use the same form as a form in VB, this will be the front page and will additionally have the following functions on it: Print, Save (CSV), Import (CSV). 3. On top of that the program will function - solely as a stand-alone program. I want to be able to modify the fields from within Access and for
2
1584
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them out of the query, it works. What seems to be happening is that if a field is NULL when it is read in through the select statement, it's causing the update statment not to find a match. I've got ConvertEmptyStringToNull not set (so it should...
1
1824
by: beil.jp | last post by:
Hi All - I'm new to Google Groups and just a novice user of Access, so please forgive me if my question is elementary: I am having a problem using the "update query" for my first time. In my database, I have two tables. Both of the tables have duplicate data, though the "Initial Data" table has many more records than the "Filter Two" table due to a process of elimination that has occurred in the past week. Both tables have 5 colums...
12
2386
by: Bruce One | last post by:
For all the ORM i have searched around, I have always found two big problems: 1) To update or delete a set of records you must first bring it to memory. If you are inside a loop and have to do it n times, then you have to query this set n times as well. Would be nice if ORM could make it easier (in a strongly type manner) to call a dynamic query to directly update/delete records. 2) I have noticed all ORM work with collection as thei...
9
3043
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
0
2877
by: imusion | last post by:
Hi, I have 2 servers each running AIX and both have a DB2 database setup on them. I'm building a news management application and in our setup we need to have a staging and production setup. So the staging database gets the changes performed and then once we're satisfied with how it looks, we push the changes through SQL queries which perform the (deletions, updating, and inserting of articles) onto the production database by comparing it to...
0
8004
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7934
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8071
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3912
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2438
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
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.