Mình mở mục này mong các bạn có kinh nghiệm nghiên cứu các lỗi trong access tìm cách khắc phục và giải thích cùng hiểu. Như mục giới thiệu rất kỹ của bạn Phát mình tóm tắt như sau:
Trong access có các sự kiện(event) và các thủ tục (procedure) ... các bạn tìm đọc thêm.
Khi ta tạo 1 form để nhập thì cần tạo các nút thực thi nhiệm vụ như: xóa,sửa,lưu,không lưu......
Khi đó sẽ hiện các lỗi mà ta bắt gặp. Để hiện thông báo lỗi và nhắc nhở người dùng ta vào sự kiện(event ) của Form đó và lựa chọn OnError sẽ vào VBA .
ví dụ tôi sử dụng code sau:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const SaiDuLieu = 2113
Const Rong = 2107 ' khai ba?o h??ng na?y co? ti?nh châ?t minh ho?a cho select case
Const TaoLao = 1670 ' khai ba?o h??ng na?y co? ti?nh châ?t minh ho?a cho select case
Const Trungkhoa = 3022
Const khoachinh = 3058
Const truongtrong = 3314
Const khonggiatri = 2046
Dim strMsg As String
Select Case DataErr
Case SaiDuLieu
Response = acDataErrContinue
strMsg = "Ban kiem tra lai du lieu da nhap xem da dung chua?. "
MsgBox strMsg, , "Bao loi !"
Case Rong
Response = acDataErrContinue
strMsg = "Ban khong the luu lai vi du lieu de trong?"
MsgBox strMsg, , "Bao loi!"
Case Trungkhoa
Response = acDataErrContinue
strMsg = "Trung khoa chinh?"
MsgBox strMsg, , "Bao loi!"
Case truongtrong
Response = acDataErrContinue
strMsg = "co it nhat 1 truong chua duoc nhap theo yeu cau"
MsgBox strMsg, , "Bao loi!"
Case khoachinh
Response = acDataErrContinue
strMsg = " khoa chinh de trong?"
MsgBox strMsg, , "Bao loi!"
Case khonggiatri
Response = acDataErrContinue
strMsg = " Lenh khong thuc hien duoc?"
MsgBox strMsg, , "Bao loi!"
Case Else
Response = acDataErrContinue
strMsg = "Co mot loi da phat sinh? "
MsgBox strMsg, , "bao loi!"
End Select
End Sub
-----------------------------------------------------------------------------------------
Mình upload các lỗi trong Access mà có thể gặp,nhưng toàn English mình đọc nhiều cái cũng rất khó hiểu. Nếu bạn nào có kinh nghiệm dịch những cái cần thiết,hoặc bạn nào gặp rồi mà không rõ thì thảo luận nha.
tAccessAndJetErrors
ErrorCode ErrorString
5 Invalid procedure call or argument
6 Overflow
7 Out of memory
9 Subscript out of range
10 This array is fixed or temporarily locked
11 Division by zero
13 Type mismatch
14 Out of string space
16 Expression too complex
17 Can't perform requested operation
18 User interrupt occurred
28 Out of stack space
47 Too many DLL application clients
48 Error in loading DLL
49 Bad DLL calling convention
51 Internal error
52 Bad file name or number
53 File not found
54 Bad file mode
55 File already open
57 Device I/O error
58 File already exists
59 Bad record length
61 Disk full
62 Input past end of file
63 Bad record number
67 Too many files
68 Device unavailable
70 Permission denied
71 Disk not ready
74 Can't rename with different drive
75 Path/File access error
76 Path not found
93 Invalid pattern string
96 Unable to sink events of object because the object is already firing events to the maximum number of event receivers that it supports
97 Can not call friend function on object which is not an instance of defining class
98 A property or method call cannot include a reference to a private object, either as an argument or as a return value
-----------------------------------------------------------------------------------------
và tiếp ....
321 Invalid file format
322 Can't create necessary temporary file
325 Invalid format in resource file
380 Invalid property value
381 Invalid property array index
382 Set not supported at runtime
383 Set not supported (read-only property)
385 Need property array index
387 Set not permitted
393 Get not supported at runtime
394 Get not supported (write-only property)
422 Property not found
423 Property or method not found
424 Object required
429 ActiveX component can't create object
430 Class does not support Automation or does not support expected interface
432 File name or class name not found during Automation operation
438 Object doesn't support this property or method
440 Automation error
442 Connection to type library or object library for remote process has been lost. Press OK for dialog to remove reference.
443 Automation object does not have a default value
445 Object doesn't support this action
446 Object doesn't support named arguments
447 Object doesn't support current locale setting
448 Named argument not found
449 Argument not optional
450 Wrong number of arguments or invalid property assignment
451 Property let procedure not defined and property get procedure did not return an object
452 Invalid ordinal
453 Specified DLL function not found
454 Code resource not found
455 Code resource lock error
457 This key is already associated with an element of this collection
458 Variable uses an Automation type not supported in Visual Basic
459 Object or class does not support the set of events
460 Invalid clipboard format
461 Method or data member not found
462 The remote server machine does not exist or is unavailable
463 Class not registered on local machine
481 Invalid picture
482 Printer error
735 Can't save file to TEMP
744 Search text not found
746 Replacements too long
2001 You canceled the previous operation.@@@1@5738@1
2002 You tried to perform an operation involving a function or feature that was not installed in this version of Microsoft Office Access.@@@1@@1
2004 There isn't enough memory to perform this operation. Close unneeded programs and try the operation again.
2005 There isn't enough free memory to start Microsoft Office Access.@Close unneeded programs and try again. For information on freeing memory, search the Microsoft Windows Help index for 'memory, troubleshooting'.@@1@@3
2006 The object name '|' you entered doesn't follow Microsoft Office Access object-naming rules.@For more information about naming objects, click Help.@@2@553714184@1
2007 You already have an open database object named '|.'@Use a different name for each database object of the same type. If you want this object to replace the original object, close the original object, and then save this object using the same name. For more information on renaming a database object, click Help.@@2@209043@1
2008 You can't delete the database object '|' while it's open.@Close the database object, and then delete it.@@1@@1
2009 You can't rename the database object '|' while it's open.@Close the database object, and then rename it.@@1@@1
2010 You can't delete the database object '|' while it's open.@Close the database object, and then delete it.@@1@@1
2011 The password you entered is incorrect.
2014 You have given this |1 the same name as an existing |2 in your database.@You can't give a table and a query the same name.@Give this object a name that isn't already used by another table or query.@1@@1
2015 There are no registered wizards of this type.@Rerun Microsoft Office Access or Microsoft Office Setup to reinstall the wizards. If you want to preserve your security or custom settings, back up the Microsoft Office Access workgroup information file. For more information on backing up files, search the Microsoft Windows Help index for 'backing up files'.@@1@@1
2016 You can't modify the attributes of System Tables.
2017 Microsoft helps protect this Visual Basic for Applications Project with a password. You must supply the password in the Visual Basic Editor before you can perform this operation.@@@1@@1
2018 The data access page name '|' you entered is misspelled or refers to a data access page that isn't open or doesn't exist.@@@1@@1
2019 The number you used to refer to the data access page is invalid.@Use the Count property to count the open data access pages and make sure that the page number is not greater than the number of open data access pages minus one.@@1@2019460@1
2020 The data access page theme name '|' you entered is misspelled or refers to a theme name that doesn't exist.@@@1@@1
2021 One or more operators in the filter expression is invalid.@For a valid list of operators refer to the help file@@1@@1
2022 You entered an expression that requires a data access page to be the active window.@@@1@5601@1
2023 The file name you specified for the data access page already exists.@@@1@5601@1
2024 The report snapshot was not created because you don't have enough free disk space for temporary work files.@To fix this, free up disk space (for example, empty the Recycle Bin or delete unnecessary files).@@1@@1
2025 The file is not in the correct format for a Microsoft Office Access project.@@@1@@1
2026 Your computer is missing at least one of the Microsoft Access 97 object libraries. Your converted database will not work until you open this database using Access 97 and then fix any missing references. @Press OK to continue saving this database in the Access 97 format with missing references, or press Cancel if you no longer wish to save this database.@@4@@2
2027 This operation is not supported for Microsoft Office Access 1.X databases.@@@1@@1
2028 Microsoft Office Access was unable to close the database object.
2029 Microsoft Office applications cannot suspend while you have documents open from a network location. Exit the applications or close the open documents and try again.
2030 The Microsoft Office Access project '|' will be opened read-only because one of the following occurredThe file is locked for editing by another user, or the file (or the folder in which it is located,) is marked as read-only, or you specified that you wanted to open this file read-only.@@1@@1
2031 You can't convert or enable an MDE file.@@@1@@1
2032 Some errors happened during the conversion. No converted database was generated.@@@1@@1
2033 Name conflicts with existing module, project, or object library.@@@1@@1
2034 Cannot Compile Project.@@@1@@1
2035 Cannot Load Project of wrong version.@@@1@@1
2036 Microsoft Office Access does not support using ADP Projects when running in Runtime Mode.@@@1@@1
2037 Microsoft Office Access could not perform name AutoCorrect during this operation. The 'Log name AutoCorrect' option is set, but the Data and Misc. Objects is not checked out.@@@1@@3
2038 The file '|' cannot be opened because it has been locked by another user.
2039 You cannot convert a workgroup file from Microsoft Access2000 to Access 97. You must create new security settings in Access 97.
2040 Microsoft Office Access can't run.@@@1@@3
2041 Microsoft Office Access couldn't find file '|'. This file is required for *******.
2042 A system error occurred, or there isn't enough free memory to start Microsoft Office Access. Close unneeded programs and try again.
2043 Microsoft Office Access can't find the database file '|.'@Make sure you entered the correct path and file name.@@1@@1
2044 You can't exit Microsoft Office Access now.@If you're running a Visual Basic module that is using OLE or DDE, you may need to interrupt the module.@@1@@1
Trong access có các sự kiện(event) và các thủ tục (procedure) ... các bạn tìm đọc thêm.
Khi ta tạo 1 form để nhập thì cần tạo các nút thực thi nhiệm vụ như: xóa,sửa,lưu,không lưu......
Khi đó sẽ hiện các lỗi mà ta bắt gặp. Để hiện thông báo lỗi và nhắc nhở người dùng ta vào sự kiện(event ) của Form đó và lựa chọn OnError sẽ vào VBA .
ví dụ tôi sử dụng code sau:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const SaiDuLieu = 2113
Const Rong = 2107 ' khai ba?o h??ng na?y co? ti?nh châ?t minh ho?a cho select case
Const TaoLao = 1670 ' khai ba?o h??ng na?y co? ti?nh châ?t minh ho?a cho select case
Const Trungkhoa = 3022
Const khoachinh = 3058
Const truongtrong = 3314
Const khonggiatri = 2046
Dim strMsg As String
Select Case DataErr
Case SaiDuLieu
Response = acDataErrContinue
strMsg = "Ban kiem tra lai du lieu da nhap xem da dung chua?. "
MsgBox strMsg, , "Bao loi !"
Case Rong
Response = acDataErrContinue
strMsg = "Ban khong the luu lai vi du lieu de trong?"
MsgBox strMsg, , "Bao loi!"
Case Trungkhoa
Response = acDataErrContinue
strMsg = "Trung khoa chinh?"
MsgBox strMsg, , "Bao loi!"
Case truongtrong
Response = acDataErrContinue
strMsg = "co it nhat 1 truong chua duoc nhap theo yeu cau"
MsgBox strMsg, , "Bao loi!"
Case khoachinh
Response = acDataErrContinue
strMsg = " khoa chinh de trong?"
MsgBox strMsg, , "Bao loi!"
Case khonggiatri
Response = acDataErrContinue
strMsg = " Lenh khong thuc hien duoc?"
MsgBox strMsg, , "Bao loi!"
Case Else
Response = acDataErrContinue
strMsg = "Co mot loi da phat sinh? "
MsgBox strMsg, , "bao loi!"
End Select
End Sub
-----------------------------------------------------------------------------------------
Mình upload các lỗi trong Access mà có thể gặp,nhưng toàn English mình đọc nhiều cái cũng rất khó hiểu. Nếu bạn nào có kinh nghiệm dịch những cái cần thiết,hoặc bạn nào gặp rồi mà không rõ thì thảo luận nha.
tAccessAndJetErrors
ErrorCode ErrorString
5 Invalid procedure call or argument
6 Overflow
7 Out of memory
9 Subscript out of range
10 This array is fixed or temporarily locked
11 Division by zero
13 Type mismatch
14 Out of string space
16 Expression too complex
17 Can't perform requested operation
18 User interrupt occurred
28 Out of stack space
47 Too many DLL application clients
48 Error in loading DLL
49 Bad DLL calling convention
51 Internal error
52 Bad file name or number
53 File not found
54 Bad file mode
55 File already open
57 Device I/O error
58 File already exists
59 Bad record length
61 Disk full
62 Input past end of file
63 Bad record number
67 Too many files
68 Device unavailable
70 Permission denied
71 Disk not ready
74 Can't rename with different drive
75 Path/File access error
76 Path not found
93 Invalid pattern string
96 Unable to sink events of object because the object is already firing events to the maximum number of event receivers that it supports
97 Can not call friend function on object which is not an instance of defining class
98 A property or method call cannot include a reference to a private object, either as an argument or as a return value
-----------------------------------------------------------------------------------------
và tiếp ....
321 Invalid file format
322 Can't create necessary temporary file
325 Invalid format in resource file
380 Invalid property value
381 Invalid property array index
382 Set not supported at runtime
383 Set not supported (read-only property)
385 Need property array index
387 Set not permitted
393 Get not supported at runtime
394 Get not supported (write-only property)
422 Property not found
423 Property or method not found
424 Object required
429 ActiveX component can't create object
430 Class does not support Automation or does not support expected interface
432 File name or class name not found during Automation operation
438 Object doesn't support this property or method
440 Automation error
442 Connection to type library or object library for remote process has been lost. Press OK for dialog to remove reference.
443 Automation object does not have a default value
445 Object doesn't support this action
446 Object doesn't support named arguments
447 Object doesn't support current locale setting
448 Named argument not found
449 Argument not optional
450 Wrong number of arguments or invalid property assignment
451 Property let procedure not defined and property get procedure did not return an object
452 Invalid ordinal
453 Specified DLL function not found
454 Code resource not found
455 Code resource lock error
457 This key is already associated with an element of this collection
458 Variable uses an Automation type not supported in Visual Basic
459 Object or class does not support the set of events
460 Invalid clipboard format
461 Method or data member not found
462 The remote server machine does not exist or is unavailable
463 Class not registered on local machine
481 Invalid picture
482 Printer error
735 Can't save file to TEMP
744 Search text not found
746 Replacements too long
2001 You canceled the previous operation.@@@1@5738@1
2002 You tried to perform an operation involving a function or feature that was not installed in this version of Microsoft Office Access.@@@1@@1
2004 There isn't enough memory to perform this operation. Close unneeded programs and try the operation again.
2005 There isn't enough free memory to start Microsoft Office Access.@Close unneeded programs and try again. For information on freeing memory, search the Microsoft Windows Help index for 'memory, troubleshooting'.@@1@@3
2006 The object name '|' you entered doesn't follow Microsoft Office Access object-naming rules.@For more information about naming objects, click Help.@@2@553714184@1
2007 You already have an open database object named '|.'@Use a different name for each database object of the same type. If you want this object to replace the original object, close the original object, and then save this object using the same name. For more information on renaming a database object, click Help.@@2@209043@1
2008 You can't delete the database object '|' while it's open.@Close the database object, and then delete it.@@1@@1
2009 You can't rename the database object '|' while it's open.@Close the database object, and then rename it.@@1@@1
2010 You can't delete the database object '|' while it's open.@Close the database object, and then delete it.@@1@@1
2011 The password you entered is incorrect.
2014 You have given this |1 the same name as an existing |2 in your database.@You can't give a table and a query the same name.@Give this object a name that isn't already used by another table or query.@1@@1
2015 There are no registered wizards of this type.@Rerun Microsoft Office Access or Microsoft Office Setup to reinstall the wizards. If you want to preserve your security or custom settings, back up the Microsoft Office Access workgroup information file. For more information on backing up files, search the Microsoft Windows Help index for 'backing up files'.@@1@@1
2016 You can't modify the attributes of System Tables.
2017 Microsoft helps protect this Visual Basic for Applications Project with a password. You must supply the password in the Visual Basic Editor before you can perform this operation.@@@1@@1
2018 The data access page name '|' you entered is misspelled or refers to a data access page that isn't open or doesn't exist.@@@1@@1
2019 The number you used to refer to the data access page is invalid.@Use the Count property to count the open data access pages and make sure that the page number is not greater than the number of open data access pages minus one.@@1@2019460@1
2020 The data access page theme name '|' you entered is misspelled or refers to a theme name that doesn't exist.@@@1@@1
2021 One or more operators in the filter expression is invalid.@For a valid list of operators refer to the help file@@1@@1
2022 You entered an expression that requires a data access page to be the active window.@@@1@5601@1
2023 The file name you specified for the data access page already exists.@@@1@5601@1
2024 The report snapshot was not created because you don't have enough free disk space for temporary work files.@To fix this, free up disk space (for example, empty the Recycle Bin or delete unnecessary files).@@1@@1
2025 The file is not in the correct format for a Microsoft Office Access project.@@@1@@1
2026 Your computer is missing at least one of the Microsoft Access 97 object libraries. Your converted database will not work until you open this database using Access 97 and then fix any missing references. @Press OK to continue saving this database in the Access 97 format with missing references, or press Cancel if you no longer wish to save this database.@@4@@2
2027 This operation is not supported for Microsoft Office Access 1.X databases.@@@1@@1
2028 Microsoft Office Access was unable to close the database object.
2029 Microsoft Office applications cannot suspend while you have documents open from a network location. Exit the applications or close the open documents and try again.
2030 The Microsoft Office Access project '|' will be opened read-only because one of the following occurredThe file is locked for editing by another user, or the file (or the folder in which it is located,) is marked as read-only, or you specified that you wanted to open this file read-only.@@1@@1
2031 You can't convert or enable an MDE file.@@@1@@1
2032 Some errors happened during the conversion. No converted database was generated.@@@1@@1
2033 Name conflicts with existing module, project, or object library.@@@1@@1
2034 Cannot Compile Project.@@@1@@1
2035 Cannot Load Project of wrong version.@@@1@@1
2036 Microsoft Office Access does not support using ADP Projects when running in Runtime Mode.@@@1@@1
2037 Microsoft Office Access could not perform name AutoCorrect during this operation. The 'Log name AutoCorrect' option is set, but the Data and Misc. Objects is not checked out.@@@1@@3
2038 The file '|' cannot be opened because it has been locked by another user.
2039 You cannot convert a workgroup file from Microsoft Access2000 to Access 97. You must create new security settings in Access 97.
2040 Microsoft Office Access can't run.@@@1@@3
2041 Microsoft Office Access couldn't find file '|'. This file is required for *******.
2042 A system error occurred, or there isn't enough free memory to start Microsoft Office Access. Close unneeded programs and try again.
2043 Microsoft Office Access can't find the database file '|.'@Make sure you entered the correct path and file name.@@1@@1
2044 You can't exit Microsoft Office Access now.@If you're running a Visual Basic module that is using OLE or DDE, you may need to interrupt the module.@@1@@1
Sửa lần cuối: