i have a problem in trying to link my listbox with its respective field in the database. when i run my program in vb6, i get all the other records populated into my form when i click on the ADODC but i couldn't get the info i entered in my listbox displayed...and in my report in MSAccess, it only shows me only one item in the list instead of, say i added 3items!
i have 2 textboxes and 2listboxes where List1 contains the filename and List2 has its respective path and is hidden. i have an ADODC to connect to my database, when i run program, the textboxes are populated with the records as i click on the adodc but the listbox doesn't seem to work. what i want is that when i click on the adodc and shows a particular user(record), it should also show me if i have added some email attachments in the listbox, but if there's no item in the listbox, then should just leave it blank/cleared.
below is my piece of code:
1. when i add a new user, i am able to view the person's record,name and address, but if i add some email attachments to the record, it doesn't get added to the respective field 'email' in my database. any ideas?
Private Sub cmdAdd_click()
Set wk1 = DBEngine.CreateWorkspace("MyWks", "admin", "", dbUseJet)
Set db1 = wk1.OpenDatabase("c:\user.mdb", False)
Set rs1 = db1.OpenRecordset("User", dbOpenDynaset)
MsgBox "Add user", vbInformation
rs3.Fields(0).Value = txtID.text
rs3.Fields(1).Value = txtName.Text
rs3.Fields(2).Value = txtAddress.Text
rs3.Fields(3).Value = List1.Text
txtID = ""
txtName = ""
txtAddress = ""
2. this is the code for when i want to update any changes made to any record. clicking on adodc need to show the appropriate email attachments in List1 and should be cleared if that user has no attachments added. meanwhile, this doesn't seem to work.
Private Sub cmdModify_Click()
If txtName.Text = "" And txtAddress.Text = ""
MyResponse= MsgBox(" Save Changes ?", vbYesNo + vbExclamation)
If MyResponse= 6 Then
cn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=c:\user.mdb; Persist Security Info=false"
rs1.Open "select * from User", cn1, adOpenDynamic
sql = "update User set " & _
"Name = '" & txtName.Text & "', " & _
"Address = '" & txtAddress.Text & "', " & _
"EmailAttachment='" & List1.Text & "' where ID = " & txtID.Text
MsgBox "User Updated", vbInformation cn1.CommitTrans
txtID.Text = Adodc1.Recordset.Fields(0).Value
txtName.Text = Adodc1.Recordset.Fields(1).Value
txtAddress.Text = Adodc1.Recordset.Fields(2).Value
List1.Text = Adodc1.Recordset.Fields(3).Value
ElseIf MyResponse = 7 Then