Hỏi:
Tôi đã xây dựng xong CT nhân sự (C:\QLNS.mdb). Tôi tạo 1 custom menu bar, giấu đi Main menu của Access, tạo form startup, disable phím Shift để không ai có thể mở được cửa sổ database. Sau một thời gian CT bị lỗi nhưng hỡi ơi tôi lại quên viết code enable phím Shift nên không tài nào mở của sổ database, mở cửa sổ viết code để sửa lại CT. Tôi phải làm sao đây ?
Đáp:
Rất đơn giản, bạn tạo 1 file .mdb mới , viết code để can thiệp vào file QLNS.mdb, enable phím Shift.
Cách làm:
Trong file .mdb mới, bạn tạo 1 form, tạo 1 command button và :
Private Sub EnableSHIFTButton_Click()
On Error GoTo ErrHandler
Dim db As Database
Dim ThuocTinh As Property
Set db = OpenDatabase("C:\QLNS.mdb")
db.Properties("AllowBypassKey") = True
Set db = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Number
If Err.Number = 3270 Then ' Property not found.
Set ThuocTinh = db.CreateProperty("AllowBypassKey", dbBoolean, True)
db.Properties.Append ThuocTinh
Resume Next
Else
MsgBox Err.Description
End If
End Sub
Không có nhận xét nào:
Đăng nhận xét