|
-
Jan 24th, 2003, 06:09 PM
#1
Thread Starter
Member
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
-
Jan 26th, 2003, 07:55 PM
#2
Sleep mode
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:
'Libraries needed for running this Code
Imports System.Data
Imports System.Data.OleDb
'open Connection to the Database with Password
Dim MyPath As String = Application.StartupPath & "\__mydb__.mdb"
Dim MyPassword As String = "passme"
Dim StrSQL As String = "Select * From MyTable"
Dim MyConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyPath & ";Jet OLEDB:Database Password=" & MyPassword)
MyConnection.Open()
'This Saves data to a DataSet and then uses update method
'against Database Source File
Dim MyCommand As New OleDbCommand(StrSQL, MyConnection)
Dim MyDataset As DataSet = New DataSet()
Dim MyAdapter As New OleDb.OleDbDataAdapter(StrSQL, MyConnection)
MyAdapter.Fill(MyDataset, "MyTable")
Dim MyDataRow As DataRow = MyDataset.Tables("MyTable").NewRow
'Fill the data in Four Columns in the Database (Fields)
MyDataRow("1_Column") = Textbox1.Text
MyDataRow("2_Column") = Textbox2.Text
MyDataRow("3_Column") = Textbox3.Text
MyDataRow("4_Column") = Textbox4.Text
MyDataset.Tables("MyTable").Rows.Add(MyDataRow)
MyAdapter.Update(MyDataset, "MyTable")
MessageBox.Show("Data Saved..", "Saved",
'if you want to write the data as well to XML file then you
'include(this)before update method
MyDataset.WriteXml(Application.StartupPath & "\_MyXMLFile_.XML")
for benefit of others as well.....
-
Jan 26th, 2003, 10:36 PM
#3
Sleep mode
you're luck .......look at this
-
Jan 26th, 2003, 11:50 PM
#4
Thread Starter
Member
pirate, my friend. Thanks for the advice!
-
Jan 26th, 2003, 11:53 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|