fernando.rosales
Registered User.
- Local time
- Today, 13:30
- Joined
- Jun 11, 2014
- Messages
- 27
Hello guys I am having trouble with a If statement. I am trying to save a record into a table when an item is Selected (highlighted blue) in a list box. Keep in mind that my listbox is set to multiple selections. I have the following code but sometimes it works and sometimes it doest.
Please help. The reason why I am trying to get this to work is because when a item is selected I will add it to the table and when an item is deselected I will delete it from a table. See my code and pictures I have attached :
Private Sub list_audits_Click()
Dim strsql As String
Dim list As String
Dim id As String
id = Me.User_ID.Value
If Me.list_audits.Selected(0) = 1 Then
With Me.list_audits
list = .Column(0)
strsql = "INSERT INTO tbl_certification (User_ID, Audit) "
strsql = strsql & "values ('" & id & "', '" & list & "') "
DoCmd.RunSQL (strsql)
End With
End If
End Sub
Please help. The reason why I am trying to get this to work is because when a item is selected I will add it to the table and when an item is deselected I will delete it from a table. See my code and pictures I have attached :
Private Sub list_audits_Click()
Dim strsql As String
Dim list As String
Dim id As String
id = Me.User_ID.Value
If Me.list_audits.Selected(0) = 1 Then
With Me.list_audits
list = .Column(0)
strsql = "INSERT INTO tbl_certification (User_ID, Audit) "
strsql = strsql & "values ('" & id & "', '" & list & "') "
DoCmd.RunSQL (strsql)
End With
End If
End Sub