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.AddNew
rs3.Fields(0).Value = txtID.text
rs3.Fields(1).Value = txtName.Text
rs3.Fields(2).Value = txtAddress.Text
rs3.Fields(3).Value = List1.Text
rs3.Update
txtID = ""
txtName = ""
txtAddress = ""
List1.Clear
End Sub
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 = ""
....
Else
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
cn1.BeginTrans
sql = "update User set " & _
"Name = '" & txtName.Text & "', " & _
"Address = '" & txtAddress.Text & "', " & _
"EmailAttachment='" & List1.Text & "' where ID = " & txtID.Text
cn1.Execute sql
MsgBox "User Updated", vbInformation cn1.CommitTrans
Adodc1.Refresh
rs1.Close
cn1.Close
Adodc1.Recordset.MoveNext
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
Exit Sub
End If
End If
End Sub