what is wrong with my code?

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
*******************************************
 
C

Col

Hi Al,

Check getCurrentUser() is not returning null
I'm not familiar with (With rs.. getrows() etc) method but shouldn't the
Withs be nested. It could be that rstR is being closed before you are using
the data.

Regards
Col
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top