A
Al
I am trying to create a new record in tblRoles after the user enter a new
project number in a form based on a different table. The code should filter a
record from tblRoles that has the user info (based on userid) then add the
info on the bottom of the tblRoles with the new project code that was entered
on the form. I keep getting an error the the values from sqlR is null?
any idea?
**********************************************
Dim db As dao.Database, rstR As dao.Recordset, rstWR As dao.Recordset, sqlR
As String, sqlWR As String
sqlR = "SELECT * FROM dbo_tblRoles Where UserID='" & getCurrentUser() &
"'"
sqlWR = "SELECT * FROM dbo_tblRoles"
Set db = CurrentDb()
Set rstR = db.OpenRecordset(sqlR)
Set rstWR = db.OpenRecordset(sqlWR, dbOpenDynaset)
With rstR
.GetRows (1)
End With
With rstWR
.AddNew
!ProjCode = Me.ProjCode
!LastName = rstR!LastName
!FirstName = rstR!FirstName
!Title = rstR!Title
!UserID = rstR!UserID
!Password = rstR!Password
!AuthorityLevel = 1
!sysRowOwner = rstR!UserID
.Update
End With
rstR.Close
rstWR.Close
db.Close
*******************************************
project number in a form based on a different table. The code should filter a
record from tblRoles that has the user info (based on userid) then add the
info on the bottom of the tblRoles with the new project code that was entered
on the form. I keep getting an error the the values from sqlR is null?
any idea?
**********************************************
Dim db As dao.Database, rstR As dao.Recordset, rstWR As dao.Recordset, sqlR
As String, sqlWR As String
sqlR = "SELECT * FROM dbo_tblRoles Where UserID='" & getCurrentUser() &
"'"
sqlWR = "SELECT * FROM dbo_tblRoles"
Set db = CurrentDb()
Set rstR = db.OpenRecordset(sqlR)
Set rstWR = db.OpenRecordset(sqlWR, dbOpenDynaset)
With rstR
.GetRows (1)
End With
With rstWR
.AddNew
!ProjCode = Me.ProjCode
!LastName = rstR!LastName
!FirstName = rstR!FirstName
!Title = rstR!Title
!UserID = rstR!UserID
!Password = rstR!Password
!AuthorityLevel = 1
!sysRowOwner = rstR!UserID
.Update
End With
rstR.Close
rstWR.Close
db.Close
*******************************************