Starting automatically a macro in Access

mulderm

Member
Join Date
Jun 2003
Location
Netherlands
Posts
298
Hello,

I am using a PLC5/25 and Microsoft Access using DDE
by RSLinx Professional.
Now I want start a macro in Access when a bit, example B3/0,
is "1".
How must I do this?

mulderm
 
Mulderm,

You will have to create a Subroutine as an Event on a Form, with proper Dimension and setup statements. Then you call your Macro, something like this:

If Word B3:0 = 1 Then DoCmd.RunMacro "Macro Name Here"
 
Last edited:
RSLinx will be required. Look at RSLinx help, under the table of contents -> collect data -> getting data into applicaitons. There is some sample VBA code there. You will have to configure a DDE link to return the B3:0 word (you can only return the word) and a VBA routine in Access that will run on a periodic interval to look at word and OR it with 1 to see if B3/0 is set. Then if the bit is set that routine will call your macro.
 
mulderm said:
I know to make a hot-link in Excel but how is
mulderm said:


this in Access?





mulderm








This is not a hotlink like in Excel where data is continually updating in a spreadsheet cell. You are going to have to create some VBA code in Access. This code must be executed periodically to look at the DDE link and assign the B3:0 to an internal word. Then that word will have to be bitwise AND-ed a mask to identify the individual bit you want, eg,





Sub PLC_Read()



'open dde link: ddetopicname=DDE Topic

RSIchan = DDEInitiate("RSLinx", "ddetopicname")

'get data and store in data variable

data = DDERequest(RSIchan, "B3:0")

‘close dde link

DDETerminate (RSIchan)

'Bitwise And data with 1 to mask all bits except B3/0

data = data And 1

'call the macro if b3/0 is set

If data then

‘whatever code you need goes here or a call to your macro.

End If

End Sub



This is only a portion of what you will need and is only an example. Look at RSLinx help for some VBA examples. This is probably something that will require at least a basic proficiency with VBA.
 
Hello,

GREAT!!!
I have some code write in the module.
This code executed periodically 1 sec when B3/0 is "1".
I have make a form with the Event Form_Timer with an
interval of 1000 (1 sec.), there is the code PLC_READ from
Alaric en these call the code in the module.
It works excellent but there is one problem.
When I open another form or Table of the database there is a delay to scroll to the records.
The cursor change every second, I think because of the Event.
Is there a solution for this problem?

Greetings,

mulderm



 
mulderm,
When a macro runs is disables the screen updating. Read below to fix this "Feature".

1. start vb editor in Excel

2. click on help

3. search for "screenupdating"

you will get answer with example code

BD
 
Mulderm, thats great! So often we don't hear back if a suggestion worked or not. Glad to hear it. I think Bikerdude pointed you in the right direction for the solution to the new problem.
 

Similar Topics

Hello, I have an RSView32 application that uses several TrendX activeX to display process values coming from different equipment. the tags loaded...
Replies
3
Views
3,080
Hello, I use RSLinx V2.43 with RSLogix5 on a Windows98 pc. Also using DDE with the Microsoft Office 2000 package. Now I want when I starting...
Replies
6
Views
4,225
Hi, I am attempting to turn on an output for one second, every thirty seconds, but am having some trouble. I have a XIC with S:1/15 (first pass)...
Replies
9
Views
643
Rather new to structured text. I'm trying to edit a machine so that it will reinitialize with some push buttons held in for 10 seconds. Pushing...
Replies
13
Views
2,793
Hi Guys, I'm using an ABL33ER with Panelview 600. I have datalogging running on the HMI using the view studio datalog model on startup of the...
Replies
4
Views
1,188
Back
Top Bottom