Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Whats Wrong With My Code?

$
0
0
Option Compare Database
Option Explicit

Private Sub SaveRecord_Click()

' Declare variables for the Database and Tables(Recordset)
' We are using DAO(Data Access Objects)
Dim db As DAO.Database
Dim rstOne As DAO.Recordset
Dim rstTwo As DAO.Recordset

' Set the variables to the current database in use and tables
Set db = CurrentDb()
Set rstOne = db.OpenRecordset("T_EMPLOYEE")
Set rstTwo = db.OpenRecordset("T_EMPLOYEE_INFO")

Dim strSQL As String

With rstOne

rstOne.AddNew
!LanID = Me.UserID
!FirstName = Me.FirstName
!MI = Me.MI
!LastName = Me.LastName
!Suffix = Me.Suffix
!EMail = Me.EMail

rstOne.Update
End With

rstOne.Close

With rstTwo

rstTwo.AddNew
!LanID = Me.UserID
!NRCOffice = Me.NRCOffice
!Division = Me.Division
!Branch = Me.Branch
!SubBranch = Me.SubBranch
!Title = Me.Title
!PayPlan = Me.CboPayPlan
!Grade = Me.CboGrade
!WorkLocation = Me.Room
!Phone = Me.Phone
!EmplInfoStatus = Me.CboEmp


rstTwo.Update
End With

rstTwo.Close

End Sub



The rstTwo.Update keeps getting highlighted saying Index or Primary Key Cannot Contain a Null Value...Please Help i Dont Know why this error messege keeps coming up?

Viewing all articles
Browse latest Browse all 13329

Trending Articles