i have a form with 5 sections; Contractor, Vacancy, HCW (Health Care Worker), CDR, Termination.
I have a listbox for each section which allows the user to select a Reason ie, lstContractorReason. Each lstbox has two columns. Column(0) is the reason and Column (1) is an IssueKey. Each lstbox will use a different IssueKey. lstContractorReason has 5 reasons to pick from and all the Issuekeys are "C". For lstVacancyReason column (0) is the reason and IssueKey is Column(1) and all values are "V" and so on.
tblPerfIssueKey has 2 fields. field 1 has the following values; P, C, V, H, T and Field 2 has the Description.
My lstbox is showing both columns on the form; Coiumns 2, 1";1"
All the fields are writing to the table except the IssueKey. txtIssueKey is on the form and the Control Source is set to IssueKey (from tblPerfIssues) which is bound to the form.
Below are 2 of the five tables and they are all set up the same.
tblContractorReason tblVacancyReason
ContractorReason VacancyReason
IssueKey IssueKey
Here is the code for the command button which writes to the tblPerfIssues.
I know this is very basic but I am not sure what I am missing!! Any help would be greatly appreciated!Code:O ption Compare Database '<-- should be at the top of every code page Option Explicit '<-- should be at the top of every code page Private Sub cmdAddPerfIssue_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim i As Variant Dim issuesValue As String On Error GoTo ErrorHandler Set db = CurrentDb() Set rs = db.OpenRecordset("tblPerfIssues") If Len(Me.cboAnalyst & vbNullString) = 0 Or Len(Me.txtReportDate & vbNullString) = 0 Or Len(Me.cboContractNumber & vbNullString) = 0 Then MsgBox "Please fill in Analyst/Specialist, Report Date and Contract Number" Else If Me.lstContractorIssues.ItemsSelected.Count = 0 Then MsgBox "Please select at least one item from Contractor Issues" Else If Len(Me.txtContractorOnset & vbNullString) = 0 Then MsgBox "Please enter a Contractor Issue Onset Date" Else With rs '<<--!!!! .AddNew rs.Fields("AnalystSpec") = cboAnalyst.Value rs.Fields("ReportDate") = Me.txtReportDate.Value rs.Fields("ContractNumber") = Me.cboContractNumber.Column("0") rs.Fields("Contractor") = Me.txtContractor.Value rs.Fields("MATO") = Me.txtMATO.Value rs.Fields("ContractorOnset") = Me.txtContractorOnset.Value rs.Fields("ContractorResolved") = Me.txtContractorResolved.Value rs.Fields("ContractorComments") = Me.txtContractorComments.Value rs.Fields("ContractorIssues") = Me.lstContractorIssues.Value rs.Fields("IssueKey") = Me.lstContractorIssues.Column("1") End With '<<--!!!! End If End If Me.lstContractorIssues = "" Me.txtContractorOnset = "" Me.txtContractorResolved = "" Me.txtContractorComments = "" Me.txtIssuekey = "" ErrorHandler_Exit: On Error Resume Next rs.Close Set rs = Nothing Set db = Nothing Exit Sub ErrorHandler: MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Workdays" Resume ErrorHandler_Exit End Sub