954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help Me

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.

kamaamin
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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"

kamaamin
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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

kamaamin
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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:)

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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.

kamaamin
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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.

kamaamin
Newbie Poster
5 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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:)

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 
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)

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: