F
Frank Schwab
Hello, everybody,
I ran into a very strange behaviour of Access 2000 and 2003 that I
can't explain. Any ideas would be very helpful. Here is what I have:
- A table "tblFiles" with an "autonum" field "filNr" and a Text(30)
field "filName".
- The table has a primary index and an unique, nonulls index on
"filName".
- There is a query "qryFilesOrderedByName" which reads "select *
from tblFiles order by filName;".
- I have a form that has "qryFilesOrderedByName" as it's data source.
- On that form is an unbound combo box which has a data source of
"qryFilesOrderedByName".
- There is also a button "btnDel" that should delete the current record.
- The code of the form reads like this:
What this effectively does is, that it shows the values of
"tblFiles" and allows to add additional file names. Now for the strange
thing:
If I press the "Del" button I get an error message that "action
RunCmd was cancelled". If I try to delete the record (which doesn't work
since it is cancelled) by pressing the "delete record" button on the
toolbar I don't get this error message.
This is a very stripped down example. The true application does a
lot more when it decides wether the delete should be cancelled or not,
but it has the strange effect that I get a "no current record" error
message when I cancel by pushing the "Del" button and no error message
when I press the "delete record" button on the toolbar.
What is happening here? Any ideas how to remedy this? Any help would
be greatly appreciated. Sorry for posting so much text.
Regards,
Frank
I ran into a very strange behaviour of Access 2000 and 2003 that I
can't explain. Any ideas would be very helpful. Here is what I have:
- A table "tblFiles" with an "autonum" field "filNr" and a Text(30)
field "filName".
- The table has a primary index and an unique, nonulls index on
"filName".
- There is a query "qryFilesOrderedByName" which reads "select *
from tblFiles order by filName;".
- I have a form that has "qryFilesOrderedByName" as it's data source.
- On that form is an unbound combo box which has a data source of
"qryFilesOrderedByName".
- There is also a button "btnDel" that should delete the current record.
- The code of the form reads like this:
Code:
Option Compare Binary
Option Explicit
Private Sub btnDel_Click()
On Error GoTo Err_btnLöschen_Click
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Exit_btnDel_Click:
Exit Sub
Err_btnDel_Click:
MsgBox Err.Description
Resume Exit_btnLöschen_Click
End Sub
Private Sub cboFile_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDateien")
'
' Add the new file to the table
'
rs.AddNew
rs!datName = NewData
rs.Update
rs.Close
Set rs = Nothing
Response = acDataErrAdded
End Sub
Private Sub Form_Current()
cboFile.Value = Me!filNr
End Sub
Private Sub Form_Delete(Cancel As Integer)
Dim i As Long
i = MsgBox("This delete is canceled!", vbExclamation + vbOKOnly,
Delete canceled")
Cancel = True
End Sub
What this effectively does is, that it shows the values of
"tblFiles" and allows to add additional file names. Now for the strange
thing:
If I press the "Del" button I get an error message that "action
RunCmd was cancelled". If I try to delete the record (which doesn't work
since it is cancelled) by pressing the "delete record" button on the
toolbar I don't get this error message.
This is a very stripped down example. The true application does a
lot more when it decides wether the delete should be cancelled or not,
but it has the strange effect that I get a "no current record" error
message when I cancel by pushing the "Del" button and no error message
when I press the "delete record" button on the toolbar.
What is happening here? Any ideas how to remedy this? Any help would
be greatly appreciated. Sorry for posting so much text.
Regards,
Frank