I am new in VB 6. I am have created text boxes and trying to add new data to the MS access. Whenever i add new data it replace the already exixting data in my table. I want new data to be entered without disturbing any existing data in my table. I am using recordset.addnew to add data. no sql commands. Could you please tell me why my new data always replace the top existing data in my table and its solution.

Show me the code where you add the actual data. Include the entire sub, i.e., if it is under a command button click event, show all the code under the event. It sounds like the add new is actually editing.

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub Command1_Click()
Adodc1.Recordset.AddNew

End Sub

Private Sub Form_Load()

End Sub

Private Sub Text1_Change()

End Sub

Private Sub Text2_Change()

End Sub
"the code is very simple, only two text boxes are used to enter new data to the table, the data is entered into the table but it replaces the already existing top data in my table. So how to entered new data without disturbing the exixting one. i have tried "update" also but it is not working either"

could you please show me an example where i can add data wihtout using any sql cmd.

This part looks fine -

Private Sub Command1_Click()
Adodc1.Recordset.AddNew

'Just add the Adodcq.RecordSet.Update
End Sub

As you have mentioned, you have tried that as well, no luck, mmmmm....

To your last question, a bit confusing. Do you want code for add new data WITHOUT using an adodc control?

If so, then the following -

Dim cnConn As ADODB.COnnection
Set cnCon = New ADODB.Connection

cnCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=YourDataBasePathHere\YourDatabaseNameHere.MDB;Persist Security Info=False"
    
Dim rsAdd As ADODB.Recordset
Set rsAdd.Recordset = New ADODB.Recordset

rsAdd.Open "SELECT * FROM MyTableNameHere", cnCon, adOpenStatic, adLockOptimistic

rsAdd.AddNew

rsAdd!MyFirstFieldNameHere = txtMyTextboxNameHere.Text
rsAdd.Update

rsAdd.Close
cnCon.Close

This should do:)

Thank you very much, your code works!!!! Now i have a project in my mind. Is it possible to built e-mail based application which send/recieve e-mail and can send reminder / follow up automatically to recevier if he dosnot reply the e-amil sent to him. The projetc is mostly on self generating e-mail. I am not sure how to start this one. I am using VB.6. I would appreciate you if through some light in this regards. I am joining a team of expert on this project and i want to equip myself with all necessary information to start with this project so that i could be an asset for the team and not a liablity. Thank you.

I am not good in SQL cmd so i try to avoid sql. Using ADODC cotrol is much easier option but i found the problem mention in my first question above that using adodc1.recorset.addnew, i am not able to add new data into my table.

Pleasure:)

That is why it is ALWAYS better to go adodb way. There is really only about 4 important sql statements to learn that will do most of what you require in an application.

Please mark this thread as solved, re-open a new post with your question about e-mail and I will gladly help you there. The reason being is to keep one post to one specific question, thanks:)

Thank you very much, your code works!!!! Now i have a project in my mind. Is it possible to built e-mail based application which send/recieve e-mail and can send reminder / follow up automatically to recevier if he dosnot reply the e-amil sent to him. The projetc is mostly on self generating e-mail. I am not sure how to start this one. I am using VB.6. I would appreciate you if through some light in this regards. I am joining a team of expert on this project and i want to equip myself with all necessary information to start with this project so that i could be an asset for the team and not a liablity. Thank you.

Would be better to create new thread and ask there instead of diverting discussion from original topic.

PS: Do not forget to mark thread as solved (there is a link bellow last post)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.