run function from another database

teel73

Registered User.
Local time
Today, 10:44
Joined
Jun 26, 2007
Messages
205
Hello,

I hope this can be achieved.

I have 2 database files.

database A has a button (buttonRun) that when clicked, it opens database B and runs the autoexec macro.

In database A, there's a label control (lblRun) next to the buttonRun that has its back style property set to transparent.

What I'm trying to accomplish is this:

After the procedure in database B completes, it exits the system. I want
lblRun's back style property to be set to normal.

I already have a function that does this and the function works fine from within the database A.

Code:
Dim frm As Form
Dim color As Variant
Set frm = Form_frmReportingDashboard
frm!lbl_cmslite.BackStyle = 1


I need to trigger that function from database B before it exits.

Is this possible?
 
Your proposal is that you "push" the visibility/transparency of the button, but it is more common to use a "pull" instead, which would eliminate the need to do what you propose.

Update your user interface to perform its own logic, based on the current state of the data, to show itself correctly. It should "pull" the data it needs at the time that it needs it.

Code:
Private Sub Form_Current()
[COLOR="Green"]   'the button is visible if value of the field is "Green"[/COLOR]
   Me.MyButton.Visible = DLookup("Colour", "TestTable", "ColourID = " & Me.ColorID) = "Green"
End Sub

That code runs for each record loaded into the form, looks at the state of the data--"pulls" on the data--and knows how to display itself accordingly. This is a much more reliable approach, and much easier to implement.

Hope it helps,
 
How does the system exit? It seems all you do in code is open the db and let the macro do it's thing.

One thing you can do is set up a timer to keep checking for the lock file.
 
I have 2 databases. When the procedure in database #2 is completed. I want to display a green control in database 1. They are 2 seperate databases, is there a way to trigger a function in one database from another database.
 
With Application.Run you can call a function in another database, but my point is, consider this scenario:
1. Db A opens Db B
2. Db A runs code in Db B
3. Db A waits for code to complete and closes Db B
4. Db A reports completion to itself

So what's the point of getting Db B to call Db A? How long does it take for the code to complete?
 
No vbaInet.. that's not correct. The scenario is like this:

1. Db A opens Db B
2. Db B runs code in Db B
3. Db B completes code procedure
4. Db A reports completion to that Db B procedure completed.

Db A is a dashboard.

The point of this is to have multiple procedures run parallel (at the same time).

Basically, I have 3 procedures. I need for them to run at the same time. The only way I know to have this done is to have 3 different accdbs. Each will have an autoexec macro that calls some function. After the procedures are completed, the databases are closed out.

All I'm trying to do is capture when the function or procedure has completed by displaying a status on Db A. (the dashboard database).
 
No vbaInet.. that's not correct.
I said ...
... consider this scenario:
... meaning, consider this approach!

Basically, I have 3 procedures. I need for them to run at the same time. The only way I know to have this done is to have 3 different accdbs.
What's the reason all three procedures have to run in tandem anyway? What exactly are they doing in very brief terms?

The problem here is you just cannot tell which db is going to complete its task before the other. Perhaps at the moment one db is completing before the other but in the future this might change hands.

I can tell you two ways of achieving your objective:

1. On completion output the completion status (1 for success or 0 for failure) to a text file from each db (i.e. one for each db) and start a timer on db A to check that all three files have been output and read their values.
2. On completion send the completion status value from the 3 dbs to db A and if it adds up to 3 then it means all completed successfully. A timer in db A will be required.
 
thanks vbaInet, I will try your approach.
 

Users who are viewing this thread

Back
Top Bottom