I assume you are not just opening the file in MSAccess but are trying to connect to it from another file? Are you using Microsoft ADO? Could you post the code you're using for the connection here?
I assume you are not just opening the file in MSAccess but are trying to connect to it from another file? Are you using Microsoft ADO? Could you post the code you're using for the connection here?
Ok thanks hmm later ill post ss and code actually in my data environment i dont use any code i just set up in properties now i want my data environment and data report that can connect to my mdb with password because i want my system run and other people cant edit mdb file
connecting from data environment to msaccess that without pass is success if I put an password in msaccess data environment cant be connected pls help me
Hmm, are you having trouble with a Jet share-level password? This isn't the best way to secure a database but it works just fine for simple situations.
If you want to simply hard-code the value it doesn't take much, you just need to set it in the right place:
Once the password has been set there, you can go ahead and test the connection:
But if you want the user to enter it at runtime you have to get a little tricky. As far as I know there isn't a shortcut for this.
In the attached demo I have used a "main form" Form1, but I have the program start by loading a "password form" Form0 to accept the password and apply it. Here's the code in Form0:
Code:
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
With DataEnvironment1.Connection1
With .Properties
![Prompt].Value = adPromptNever
![Jet OLEDB:Database Password].Value = Trim$(txtPW.Text)
End With
On Error Resume Next
.Open
If Err Then
MsgBox "Incorrect password"
txtPW.Text = ""
txtPW.SetFocus
Exit Sub
End If
On Error GoTo 0
End With
Form1.Show
Unload Me
End Sub
Seems to work just fine.
To try the demo you should be able to just unZIP the archive and open the VBP in the VB6 IDE and run it. The required password is given in a "hint" shown in Form0 ("supersecret").
Hmm, are you having trouble with a Jet share-level password? This isn't the best way to secure a database but it works just fine for simple situations.
If you want to simply hard-code the value it doesn't take much, you just need to set it in the right place:
Once the password has been set there, you can go ahead and test the connection:
But if you want the user to enter it at runtime you have to get a little tricky. As far as I know there isn't a shortcut for this.
In the attached demo I have used a "main form" Form1, but I have the program start by loading a "password form" Form0 to accept the password and apply it. Here's the code in Form0:
Code:
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
With DataEnvironment1.Connection1
With .Properties
![Prompt].Value = adPromptNever
![Jet OLEDB:Database Password].Value = Trim$(txtPW.Text)
End With
On Error Resume Next
.Open
If Err Then
MsgBox "Incorrect password"
txtPW.Text = ""
txtPW.SetFocus
Exit Sub
End If
On Error GoTo 0
End With
Form1.Show
Unload Me
End Sub
Seems to work just fine.
To try the demo you should be able to just unZIP the archive and open the VBP in the VB6 IDE and run it. The required password is given in a "hint" shown in Form0 ("supersecret").
hmmm I get an idea in form0 I will make an trick automatic connect to database
just change the properties of txtPW.Text = password of your database
the user will not notice that system has a password in database I think it more secure ^^ thanks sir it helps me a lot now my project on thesis almost 90% done if you want I can share with you ^^
Private Sub Form_Load()
With DataEnvironment1.Connection1
With .Properties
![Prompt].Value = adPromptNever
![Jet OLEDBatabase Password].Value = Trim$(txtPW.Text)
End With
Form1.Show
Unload Me
end sub
Can't read the error message, If you want to post the screen that the error is on you should crop it to where it is just the msgbox so that it does not get scaled down so small, no need for all that other stuff in there and can't read the important part.
Can't read the error message, If you want to post the screen that the error is on you should crop it to where it is just the msgbox so that it does not get scaled down so small, no need for all that other stuff in there and can't read the important part.
The error mssg is "read only property value was not set"
Hard to diagnose from here with so little information.
Perhaps you tried to set the password value after the Connection was already open, or already bound to a control?
This was why I used a Form0 to handle the process, before Form1 which uses the DataEnvironment was ever loaded. You could probably also do this in Form1 by breaking the design-time data binding (for example deleting DataMember) and then setting it at runtime after setting the password.
Hard to diagnose from here with so little information.
Perhaps you tried to set the password value after the Connection was already open, or already bound to a control?
This was why I used a Form0 to handle the process, before Form1 which uses the DataEnvironment was ever loaded. You could probably also do this in Form1 by breaking the design-time data binding (for example deleting DataMember) and then setting it at runtime after setting the password.
Sir thanks for the help atm im not infront of my loptop i was thinking maybe i found the solution in my module i have an function submain which contain of connecting to my database i was thinking that may code has conflict with this later ill post the result ^_^
datamiser and dilettante thanks both of you guys I found out the solution of my problem here guys I share with you about on How to connect in msaccess that has a ms acess pasword in data environment and data report
create 1 form contain in command button I name it cmdprint then in data report name it rptperson and database I name it invdata inside database create a table I name it EmpMaster and it has the ff fields EmpName , Desig , Add, City, Phone, Mobile
Create 1 module
Code:
Sub Main()
On Error GoTo errConn
Set cn = New ADODB.Connection
Dim conString As String
conString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & App.Path & "/DataBase/InvData.mdb" _
& ";;Jet OLEDB:Database Password=nthski;"
cn.Open conString
form1.Show
Exit Sub
errConn:
MsgBox Err.Description
End
End Sub
'code in form1
Private Sub cmdprint_Click()
Set rec = New ADODB.Recordset
rec.Open "select * from EmpMaster where EmpName = '" & txtName.Text & "' ", cn, adOpenStatic, adLockOptimistic
'search = "SELECT * FROM EmpMaster WHERE EmpName = '" & searching & "'"
If rec.RecordCount > 0 Then
With rptperson
Set rptperson.Sections("Section1").Controls("Image1").Picture = LoadPicture(txtPath.Text)
Set rptperson.DataSource = rec
.Sections("Section1").Controls("txtname").DataField = "EmpName"
.Sections("Section1").Controls("txtDesig").DataField = "Desig"
.Sections("Section1").Controls("txtAddress").DataField = "Add"
.Sections("Section1").Controls("txtCity").DataField = "City"
.Sections("Section1").Controls("txtPhone").DataField = "Phone"
.Sections("Section1").Controls("txtMobile").DataField = "Mobile"
.Show
End With
End If
create 1 report that has a rpttextbox name it txtname , txtDesig, txtAddress, txtCity, txtPhone, txtMobile