Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    6

    Unanswered: Saving data to table from form w/ Multi-Select Listbox

    I am working with a database that records "Journal Entries" that supervisors create for their direct report employees. I have just created a new Entry form that allows the supervisor to select multiple employees through the use of a multi-select listbox. I have code that will enter the "Journal Entry" for all of the employees that the supervisor selects, but I am also getting a 'Blank' entry as well. What I mean by a blank entry is that there is always an entry made that has a blank field for the employee’s name. Any help in preventing this 'Blank' entry would be greatly appreciated. Here is the code that I am currently using:

    Code:
    Dim varValue As Variant
     
    With Me.AgentName
        For Each varValue In .ItemsSelected
             CurrentDb.Execute "INSERT INTO [Journal Data] ([Agent], [Coach], [Action_Date], [Action_Reason], [Journal_Entry], [Entry_Date], [Entered_By]) Values " & _
                        "('" & Me.AgentName.Column(0, varValue) & "','" & Me.CoachName & "',#" & Me.ActionDate & "#,'" & Me.JournalReasonDropDown & "','" & Me.JournalMemo & "',#" & Me.CurrentDate & "#,'" & Me.Text34 & "')"
       Next
    End With

  2. #2
    Join Date
    Dec 2010
    Posts
    6
    I figured it out. My form was Bound to the table. I just unbound all of the fields in the form and let the code do the work. This stopped the blank entry from being created.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •