Ok, here's another problem which i really need help.

One suggestion from our panel suggested if we can have a module which do not allow deleting a record (one or more) in the database which are Administrator type.

Those records cannot be deleted whether through

1. the program itself (via code) or
2. directly from the database (w/o setting password for the database file).

Regarding number 2, i really have no idea.

On number 1, here's my code for deleting files:

Private Sub cmdDelete_Click()

 ' On Error GoTo err
    Dim intYN
    intYN = MsgBox("You are about to delete a record." & vbCrLf & _
        "If you click Yes, you won't be able to undo this delete operation." & _
        vbCrLf & vbCrLf & _
        "Are you sure you want to delete this record?", vbExclamation + vbYesNo, "Confirm Delete")
    If intYN = vbNo Then Exit Sub
    DBLink.Execute "Delete From Users Where ID = " & lvwUser.SelectedItem.Text
    Call Form_Load
    txtName.Text = ""
    txtPass.Text = ""
    txtConfirm.Text = ""
    MsgBox "The Record has been deleted.", vbInformation

    Exit Sub
    MsgBox Err.Description, vbCritical

End Sub


:D This is just a trick that might work for # 2. Just follow this steps

1. Right click your Database (*.mdb) > Properties > Tick Read-Only

This will not allow user to make any changes in your database. simple trick right? :D

2. In you VB6 code, use the SetAttr function to set the database to normal (remove read only property)

Use this code to make your database back to normal. Use it before you connect.

Dim DatabaseLocation as String
DatabaseLocation = "D:\SilentProject Softwares\Property and Sales Information\Database\Database.mdb"
Call SetAttr(DatabaseLocation, vbNormal)

Now use this code to make your database as read only. Use it before terminating your application.

Dim DatabaseLocation as String
DatabaseLocation = "D:\SilentProject Softwares\Property and Sales Information\Database\Database.mdb"
Call SetAttr(DatabaseLocation, vbReadOnly)

Hope this solves your problem. :D

My database connection is via module.

Public cmd As Command
Public DBLink As New ADODB.Connection
Public RecSet As New ADODB.Recordset

Public EnrollFPType As String
Public FPTPath As String

Public Sub Con(Database As String)

DBLink.Provider = "Microsoft Jet 4.0 OLE DB Provider"
DBLink.ConnectionString = "Data Source=" & App.Path & "\" & Database
DBLink.Open ""

End Sub

And i call it in every form that needs that connection.

So how do i add this codes.

Add the first code in line 11 so it will be set to normal. Then the second code will just be before you exit the application or before calling the END keyword that would terminate the application so that it will return in Read Only Mode.

Thanks. The first code works well.

But the second one do not. After i exit the program and view my database property, the Read Only is unchecked.

Here's my code for the program exit.

Private Sub mnuExit_Click()

Dim strMess
If LogOff = False Then

    strMess = "You are about to close the Automated Payroll System." & vbCrLf & vbCrLf & "Are you sure?"
    If MsgBox(strMess, vbQuestion + vbYesNo, "Exit Confirmation") = vbYes Then

        Dim DatabaseLocation as String
        DatabaseLocation = App.Path & "\" & Database
Call SetAttr(DatabaseLocation, vbReadOnly)
        Cancel = 1
    End If
ElseIf LogOff = True Then

    Unload Me
End If
End Sub

I ticked the Read Only property before testing your code.

Don't know what is wrong with it but its working in my code. Make sure your DatabaseLocation is your full database path.

Private Sub Form_Unload(Cancel As Integer)
    Call SetAttr(DatabaseLocation, vbReadOnly)
End Sub

WOrking now.

Change line 12 to :

DatabaseLocation = App.Path & "\Database.mdb"

Thanks, really appreciate it.

Your Welcome! Glad to help fellow Filipino. :D