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.
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.
Comment