Dear f riends,
i have two forms connected to two tables in ms access database with data control. and i want to link two field in two forms and update database . i used the following code for updating text1.text=form2.text1.text in form1 text1 lost focus event. but iam not understanding how to update databse. so i reqest any body to give the code for updating database and in which event i have to write in form1 only because i want to update from form1 only

Recommended Answers

All 9 Replies

What kind of database do you have? How do you want to update it? Automatically?

What kind of database do you have? How do you want to update it? Automatically?

i have MS access database having two tables in it table1,table2

Yeah. But by which means do you plan to update them? According to a certain rule, or randomly or according to user input?

when i input data in form1.text field , the table2 which i have connected to form2.text with datacontrol , should be updated. this is problem. iam connecting form1, form2 by using code text1.text= form2.text1.text. but how to update database automatically and in which event , i have to enter the code , iam not understanding

As you've probably done, keep two different forms - one would be your main form (the startup form) and second would be for updating the database. You can for example keep a password protection for accessing the second form so that the database is updated by authorized people only.

Dear f riends,
i have two forms connected to two tables in ms access database with data control. and i want to link two field in two forms and update database . i used the following code for updating text1.text=form2.text1.text in form1 text1 lost focus event. but iam not understanding how to update databse. so i reqest any body to give the code for updating database and in which event i have to write in form1 only because i want to update from form1 only

[CODE= 'To update a database, depending on the data control, if intrinsic, use for instance, Data1.Recordset.Update. Assuming Data1 is used for the databound control.
Private Sub Command1_Click()
Data1.Recordset.Update
Data1.Refresh
End Sub ]

thankyou for giving reply. But here iam using 2 datacontrols separetely for form1, form2 for connecting table1,table2 in database. hence i think you have code for updating table1 only. but what about table2. how it can be updated from form1 only.
please give me code for it

To update a database on say Form1 from Form2, precede the same code with the form name, i.e., on Form1 use this code:

Private Sub Command1_Click()
Form2.Data1.Recordset.Update
Form2.Data1.Refresh
End Sub

Hi David, Use code tags as I've done here: You probably added an extra space in

[/code ]

'To update a database on say Form1 from Form2, precede the same code with the form name, i.e., on Form1 use this code:
Private Sub Command1_Click()
Form2.Data1.Recordset.Update
Form2.Data1.Refresh
End Sub
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.