4 Replies - 691 Views - Last Post: 17 August 2017 - 07:12 AM Rate Topic: -----

#1 infinuscerro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-August 17

Help with VB6 refreshing ADODC problem

Posted 06 August 2017 - 06:08 AM

I have 2 program, very simple VB6 program to add data into ms-access(.mdb) and the other program is just viewing the data.

Program A run on PC-1 and Program B run on PC-2

1. Program A

https://ibb.co/dYEh9v

Private Sub Command1_Click()
Adodc1.Recordset.Addnew
Adodc1.Recordset.Field(0) = Text1.Text
Adodc1.Recordset.Field(1) = Text2.Text
Adodc1.Recordset.Update
End SUb

(Program A is working OK, it just use to insert data into .mdb)

2. Program B

https://ibb.co/g3JLwa

It just datagrid to view data from ms-access. The data was input using Program A on PC-1.

(Program B is working properly to display data, but when I add data from Program A the data was not display last record that I've added)

My problem is when i add the data from Program1, Program2 is not display the data that I have just enter it. These 2 program are running together on each computer.

The datagrid can view my last data only if i close Program B and open it again. If i add command button on Program B to refresh adodc then the data is displayed.

But I need the adodc to automatically refresh when there is data change.

Help me pls

Is This A Good Question/Topic? 0
  • +

Replies To: Help with VB6 refreshing ADODC problem

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 328
  • View blog
  • Posts: 1,990
  • Joined: 26-March 09

Re: Help with VB6 refreshing ADODC problem

Posted 11 August 2017 - 11:34 PM

I've never used the control, but if the data is changed in another program and you need your program to update, can you not do it on a timer and call the refresh code in the timer event?
Was This Post Helpful? 0
  • +
  • -

#3 infinuscerro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-August 17

Re: Help with VB6 refreshing ADODC problem

Posted 12 August 2017 - 06:53 AM

View Postmaj3091, on 11 August 2017 - 11:34 PM, said:

I've never used the control, but if the data is changed in another program and you need your program to update, can you not do it on a timer and call the refresh code in the timer event?


I know about your suggestion is to put adodc1.refresh code in timer event.
But I want to know is there another way to detect adodc for data change event maybe?
Was This Post Helpful? 0
  • +
  • -

#4 thx1138v2  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 09-March 17

Re: Help with VB6 refreshing ADODC problem

Posted 15 August 2017 - 08:00 PM

There are several ways to do "interprocess communication". Search that term. They can, however, get very complex if you have more than one user running each of the programs.

The basic concept is that program A sends a message to program B whenever program A adds a record. Program B can either sit in a loop "listening" for the text file to change or it can check the message queue occasionally based on a timer. The method depends on what you are doing and how critical the response time is.

The simplest way to do it is with another file. Program A writes out "new record" to a text file when appropriate. When program B starts, it captures the time stamp of the text file and it then checks for a change in that time stamp. If the file time stamp has changed, it opens the file, reads the message and performs its function and keeps track of the last time stamp encountered so it will know when the next change happens. In this manner program A can send different messages for program B to act upon, like new record, update record, delete record. In your example you wouldn't need that functionality but keep it in mind.

You just need to check the time stamp, update the last time stamp received, and query and display the new information.
Was This Post Helpful? 0
  • +
  • -

#5 infinuscerro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-August 17

Re: Help with VB6 refreshing ADODC problem

Posted 17 August 2017 - 07:12 AM

I found this article about "interprocess communication" that you talked about. http://www.thescarms...asic/ddeml.aspx. I am still learning that article now.
Thanks for your suggestion.

This post has been edited by andrewsw: 17 August 2017 - 11:41 AM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1