|
Prev: Split cells
Next: DoCmd.OpenReport
From: Lee Allen on 5 Jul 2006 11:00 I recently converted an Access 97 Application to Access 2003. When I use this forms combo box, I get the f ollowing error in a dialog box "RUN TIME ERROR 2501 the save action was cancelled", when I update the combo box for which the beforeUpdate Code is below, the debugger screen goes directly to the line about DoCmd.Save in the code below. Private Sub cmbTreatment_BeforeUpdate(Cancel As Integer) Dim rstTreatment As Recordset Set dbs = CurrentDb i = vbOK 'If Me.cmbTreatment.Value <> Me.cmbTreatment.OldValue Then If Len(strHNickname) > 0 Then i = MsgBox("This action will replace the current treatment, do you wish to continue?", vbOKCancel) End If If Len(strHNickname) < 1 Or i = vbOK Then Set rstTreatment = dbs.OpenRecordset("Select TREATMENT,NICKNAME from tbl_Treatment where trim(NICKNAME) = '" & Trim(Me.cmbTreatment.Value) & "'") If rstTreatment.RecordCount > 0 Then Me.TREATMENT = rstTreatment("treatment") Me.TREAT_NICK_NAME = rstTreatment("nickname") ' Me.cmbTreatment.Text = rstTreatment("nickname") DoCmd.Save strHCase = Me.CASE_ID lNoEdit = True Me.oleTreatment.Value = rstTreatment("treatment") ' Me.cmbTreatment.Text = rstTreatment("nickname") End If Else ' Call LoadCaseFields Me.oleTreatment.Value = Me.oleTreatment.OldValue End If 'End If End Sub Any Ideas? Lee
From: Steve Schapel on 6 Jul 2006 05:24 Lee, DoCmd.Save refers to changes to the design of the current database object. It is not relevant to your data. It normally would be applied when the form is in Design View, not when you are in the middle of manipulating data and the value of controls. If you are intending to save the current record, then the applicable method would be... DoCmd.RunCommand acCmdSaveRecord -- Steve Schapel, Microsoft Access MVP Lee Allen wrote: > I recently converted an Access 97 Application to Access 2003. > > When I use this forms combo box, I get the f ollowing error in a dialog box > "RUN TIME ERROR 2501 the save action was cancelled", > > when I update the combo box for which the beforeUpdate Code is below, the > debugger screen goes directly to the line about DoCmd.Save in the code below. > > Private Sub cmbTreatment_BeforeUpdate(Cancel As Integer) > Dim rstTreatment As Recordset > > Set dbs = CurrentDb > i = vbOK > 'If Me.cmbTreatment.Value <> Me.cmbTreatment.OldValue Then > If Len(strHNickname) > 0 Then > i = MsgBox("This action will replace the current treatment, do you > wish to continue?", vbOKCancel) > End If > > If Len(strHNickname) < 1 Or i = vbOK Then > Set rstTreatment = dbs.OpenRecordset("Select TREATMENT,NICKNAME from > tbl_Treatment where trim(NICKNAME) = '" & Trim(Me.cmbTreatment.Value) & "'") > If rstTreatment.RecordCount > 0 Then > Me.TREATMENT = rstTreatment("treatment") > Me.TREAT_NICK_NAME = rstTreatment("nickname") > ' Me.cmbTreatment.Text = rstTreatment("nickname") > DoCmd.Save > strHCase = Me.CASE_ID > lNoEdit = True > Me.oleTreatment.Value = rstTreatment("treatment") > ' Me.cmbTreatment.Text = rstTreatment("nickname") > End If > Else > ' Call LoadCaseFields > Me.oleTreatment.Value = Me.oleTreatment.OldValue > End If > 'End If > > End Sub > > Any Ideas? > > > Lee
|
Pages: 1 Prev: Split cells Next: DoCmd.OpenReport |