why does my form does not Update?

andrew_perez5

Registered User.
Local time
Today, 14:34
Joined
Jan 3, 2005
Messages
12
Can anybody help me with my problem pls?
I created a form(labeled "form1") in MS Access 2000 with all the fields coming from a table(labeled "Table1") with one button(labeled "Update"). Once I click this "Update" button, all the data values from a table from another MS Access database(different from where I created the form) should be transferred to "Table1".I have no problems with that since my code is really transferring the data values from another database to my "Table1". The problem is it does not update the form("form1"). What I need is that once i click the "Update" button, both the table and the form should be updated or refreshed.What happens is that once I click the "Update" button, the form remains empty not until i close it then Open again then that's the only time that i will see the values in the fields. Could anybody help me pls....pls...pls...

BON
 
Andrew

In your "Update" button code, try adding Me.Requery after the update command.

peter
 
Peter,
It still does not work. Do you think its possible?Any other ideas...
Bon
 
Andrew,

Could you paste the code that is behind the Update button?

Like Peter said, the last line should be:

Me.ReQuery

Wayne
 
Private Sub cmd_add_Click()
On Error GoTo Err_cmd_add_Click
Dim cnn_source As New ADODB.Connection
Dim cnn_target As New ADODB.Connection
Dim rs_source As New ADODB.Recordset
Dim rs_target As New ADODB.Recordset

cnn_source.CursorLocation = adUseClient
cnn_target.CursorLocation = adUseClient

cnn_source.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\export.mdb;Mode=ReadWrite;Persist Security Info=False"
cnn_source.Open

cnn_target.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\sample2.mdb;Mode=ReadWrite;Persist Security Info=False"
cnn_target.Open

rs_source.ActiveConnection = cnn_source
rs_source.CursorType = 1
rs_source.LockType = 3

rs_target.ActiveConnection = cnn_target
rs_target.CursorType = 1
rs_target.LockType = 3


rs_source.Open "SELECT * from [VCLOG]"

rs_target.Open "SELECT * from [tbl_Call_Information]"

'this is the actual code that inserts data to my table and i want my form to be updated as well
Do While rs_source.EOF = False
cnn_target.Execute "INSERT INTO tbl_Call_Information (Extension,AgentId) values ('" & rs_source!Extension & "','" & rs_source!AgentId & "')"
rs_target.Requery
rs_target.MoveLast
rs_source.MoveNext
Me.Requery
Loop

DoCmd.GoToRecord , , acNewRec

Exit_cmd_add_Click:
Exit Sub

Err_cmd_add_Click:
MsgBox Err.Description
Resume Exit_cmd_add_Click
rs_source.Close
rs_target.Close
cnn_source.Close
cnn_target.Close



End Sub
 
I already tried putting Me.Requery both inside the loop and outside the loop after the insertion of records.
 
I'm no expert with code but:

DoCmd.GoToRecord , , acNewRec

will bring up a new (blank) record on the form.
Also, and has been pointed out to you, the last line should be Me.Requery

Replace one with the other.
 
It still does not work. I removed

DoCmd.GoToRecord , , acNewRec

but it did not make any difference. I put Me.Requery inside my loop and even at the end of the program(Before end sub) to make sure its gonna refresh the form but it did not work I s there any way to refresh a form?Or maybe is it ok to put inside the Update button a line that will close and open the form?
 

Users who are viewing this thread

Back
Top Bottom