Saving multiple selections in a listbox on a form

I Figured It Out!!!

For anyone who is following this, I FINALLY managed to fix my problem with this code (slightly altered from an attachment posted by Jinky44 posted on 12/30/03 at 01:51 AM)
at: http://www.utteraccess.com/forums/showflat.php?Cat=&Number=355743
This was an answer to someone else's post.

Thanks Jinky!!! I have been working on this problem for WEEEEEEEKS! I LOVE this...short, sweet, and to the point!

The code is on the OnClick event for the cmdNextQuestion button next to the question on the sub-subform frmActiveQuestion.

Code:
Private Sub cmdNextQuestion_Click()
    
Dim ctlAnswer As Control
Dim varItm As Variant, intI As Integer
Dim strPick As String
Set ctlAnswer = Forms!frmSurvey!subActiveAnswer!cboAnswerID
For Each varItm In ctlAnswer.ItemsSelected          'now process selected items...
    If varItm >= 0 Then                         'selected item?
      strPick = "Insert into qrySavedAnswers(CompletedSurveyID, AnswerID) Values (" & Forms!frmSurvey!subActiveAnswer!txtCompletedSurveyID & _
              ", " & ctlAnswer.Column(0, varItm) & ");"
'      MsgBox strPick     'To view what numbers are being saved for troubleshooting
    xSql strPick
    End If
    
Next varItm
DoCmd.GoToRecord , , acNext
Forms!frmSurvey!subActiveAnswer!cboAnswerID.Requery
Forms!frmSurvey!subActiveAnswer.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec
    
End Sub

There is also an associated module...
Code:
Public Sub xSql(xArg As String)
  On Error Resume Next
  DoCmd.SetWarnings False
  DoCmd.RunSQL xArg
  DoCmd.SetWarnings True
End Sub

Thanks for EVERYONE's time and assistance!!!!
 
Bravo!

Kila said:
For anyone who is following this, I FINALLY managed to fix my problem with this code (slightly altered from an attachment posted by Jinky44 posted on 12/30/03 at 01:51 AM)
at: http://www.utteraccess.com/forums/showflat.php?Cat=&Number=355743
This was an answer to someone else's post.
BRAVO!

I must have missed your most recent posts or I would have tried to help you out but I am glad you were able to find what you needed in a previous post!
:)
(even if it is on another forum!)
:eek: :p
 
Thank you!!

Thanks for ALL your help anyway. I could not have gotten nearly as far without you! I thought I would add that last note just in case someone with a similar problem was looking for the final solution.
 

Users who are viewing this thread

Back
Top Bottom