I have a form that has three feilds, one being a drop down menu that are used
to add a user, password, and security level to a database. When you open the
form those fields bring up the first record in the table and can also be used
to browse and delete entries in the table. The problem I am having is this.
After you enter a user and open the form a second time, it adds a duplicate
entry to the table but without the password. Can any one direct me towards a
solution?
TIA
Code-----------------------------------------
Option Compare Database
-----------------------------------------------
Private Sub btnDelete_Click()
Dim db As Database
Dim rstUser As Recordset
Dim intCount As Integer
Set db = CurrentDb
Set rstUser = db.OpenRecordset("AppUsers", dbOpenDynaset)
intCount = 0
Do While Not rstUser.EOF
If rstUser!User_Name = Me!txtUser Then
rstUser.Delete
intCount = intCount + 1
End If
rstUser.MoveNext
Loop
End Sub
------------------------------------------------
Private Sub CmdNewRec_Click()
Dim db As Database
Dim rstUser As Recordset
Dim rstPass As Recordset
Dim rstSec As Recordset
Set db = CurrentDb()
Set rstUser = db.OpenRecordset("AppUsers", dbOpenDynaset)
With rstUser
.AddNew
![User_Name] = Me!txtUser
![User_Password] = Me!txtPass
![Sec_Level_ID] = cboSec
.Update
End With
End Sub
-------------------------------------------------
Private Sub CmdExit_Click()
DoCmd.OpenForm "OBR_Resources"
DoCmd.Close acForm, "FrmUsers"
End Sub
Rob Oldfield - 13 Dec 2005 02:28 GMT
Two points:
On the question as you post it - if it's adding a duplicate record the
second time that you open it then it's down to how you are doing that, and
not because of code in the form itself. You'd need to post the code that is
opening the form to get any help.
On what you're trying to do via this form - it's completely pointless. Even
if you get your code completely successful, then you have *NO* security.
This is the way to go:
http://support.microsoft.com/default.aspx?scid=kb;en-us;207793 - complicated
but, if you want any level of security, necessary.
> I have a form that has three feilds, one being a drop down menu that are used
> to add a user, password, and security level to a database. When you open the
[quoted text clipped - 53 lines]
>
> End Sub