R
rc51wv
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
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