Results 1 to 5 of 5

Thread: Simple Access Security Solution?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54

    Lightbulb Simple Access Security Solution?

    Simple Access Security Solution!
    I am using an Access Db (.mdb) as a backend database. The information contained is not sensitive and most of the users aren't that computer literate. I planned on setting up a password for the Db, but after reading all the forums it seems like a real nightmare (I've tried before w/ no luck). So I think I'll take the easy road: Use VBA to close Access every time the form attempts to load. I do realize that just by holding down shift it could disable the macro. My question is how the heck do I get a macro to excute upon loading the Db? I am very familar w/ Excel but somewhat new to Access. I am using this code in a module

    Public Sub Application_Startup ()
    docmd.Quit ()
    End Sub

    No luck getting this to run on startup. . Please advise...
    I know that in Excel I could put the code in THIS WORKBOOK, what the best for ACCESS

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't recommed that old-fasion ways . Don't miss the sweetness of using ADO.NET , DataSets , DataAdapters ...etc. If you're facing any problems concerning Security and password , now here is the solution otherwise you can try posting this tread in General Visual Basic .You will find someone helpful .
    VB Code:
    1. 'Libraries needed for running this Code
    2.         Imports System.Data
    3.         Imports System.Data.OleDb
    4.  
    5.  
    6.  
    7.     'open Connection to the Database with Password
    8.     Dim MyPath As String = Application.StartupPath & "\__mydb__.mdb"
    9.     Dim MyPassword As String = "passme"
    10.     Dim StrSQL As String = "Select * From MyTable"
    11.     Dim MyConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyPath & ";Jet OLEDB:Database Password=" & MyPassword)
    12.         MyConnection.Open()
    13.  
    14.     'This Saves data to a DataSet and then uses update method
    15.     'against Database Source File
    16.     Dim MyCommand As New OleDbCommand(StrSQL, MyConnection)
    17.     Dim MyDataset As DataSet = New DataSet()
    18.     Dim MyAdapter As New OleDb.OleDbDataAdapter(StrSQL, MyConnection)
    19.  
    20.  
    21.         MyAdapter.Fill(MyDataset, "MyTable")
    22.     Dim MyDataRow As DataRow = MyDataset.Tables("MyTable").NewRow
    23.     'Fill the data in Four Columns in the Database (Fields)
    24.         MyDataRow("1_Column") = Textbox1.Text
    25.         MyDataRow("2_Column") = Textbox2.Text
    26.         MyDataRow("3_Column") = Textbox3.Text
    27.         MyDataRow("4_Column") = Textbox4.Text
    28.         MyDataset.Tables("MyTable").Rows.Add(MyDataRow)
    29.         MyAdapter.Update(MyDataset, "MyTable")
    30.         MessageBox.Show("Data Saved..", "Saved",
    31.  
    32.     'if you want to write the data as well to XML file then you
    33.     'include(this)before update method
    34.         MyDataset.WriteXml(Application.StartupPath & "\_MyXMLFile_.XML")

    for benefit of others as well.....

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    you're luck .......look at this

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    54
    pirate, my friend. Thanks for the advice!

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Welcome anytime . just get into ADO.NET Paradise ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width