Hello, I have an AddEmployee form that is linked to my employee table. it has simple text boxes for the user to input information. i created two combo boxes, one pointing to the department table and the other pointing to the projects table. im using this code to add a new record, and it inputs it into the table correctly, but the CurrentDepartment and CurrentProjects fields in the employee table are always blank, even if the user selected a department or project from the combo box.
Private Sub cmdSave_Click()
Dim rs As Recordset
Dim fld As Field
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Employees")
If IsNull(FirstName) Then
MsgBox "You must enter a First Name.", vbOKOnly
Exit Sub
End If
With rs
.AddNew
.Fields("FirstName").Value = FirstName
.Fields("LastName").Value = LastName
.Fields("PhoneNumber").Value = PhoneNumber
.Fields("Address").Value = Address
.Fields("City").Value = City
.Fields("State").Value = State
.Fields("ZIP").Value = ZIP
.Fields("DateHired").Value = DateHired
.Fields("DateTerminated").Value = DateTerminated
.Fields("CurrentDepartment").Value = Combo76.Value
.Fields("CurrentProject").Value = Combo78.Value
.Fields("Salary").Value = Salary
End With
rs.Close
Set rs = Nothing
Forms!Employees.List72.Requery
DoCmd.Close
Exit Sub
End Sub
i tried:
.Fields("CurrentDepartment").Value = Combo76
.Fields("CurrentProject").Value = Combo78
and it still doesnt work
thanks for the help!
Private Sub cmdSave_Click()
Dim rs As Recordset
Dim fld As Field
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Employees")
If IsNull(FirstName) Then
MsgBox "You must enter a First Name.", vbOKOnly
Exit Sub
End If
With rs
.AddNew
.Fields("FirstName").Value = FirstName
.Fields("LastName").Value = LastName
.Fields("PhoneNumber").Value = PhoneNumber
.Fields("Address").Value = Address
.Fields("City").Value = City
.Fields("State").Value = State
.Fields("ZIP").Value = ZIP
.Fields("DateHired").Value = DateHired
.Fields("DateTerminated").Value = DateTerminated
.Fields("CurrentDepartment").Value = Combo76.Value
.Fields("CurrentProject").Value = Combo78.Value
.Fields("Salary").Value = Salary
End With
rs.Close
Set rs = Nothing
Forms!Employees.List72.Requery
DoCmd.Close
Exit Sub
End Sub
i tried:
.Fields("CurrentDepartment").Value = Combo76
.Fields("CurrentProject").Value = Combo78
and it still doesnt work
thanks for the help!