Form with row of data button to run macro with some of the data

iamtim

New member
Local time
Today, 18:05
Joined
Dec 11, 2021
Messages
8
It's difficult to even come up with a title for what I am trying to do.

I have a form that has a display of filtered results. Each row has "PartN", "Disc", and "Price".

I want to add a button at the end of each row that will run a command that will run a python script. But, when it runs that command, I want it to run the script with the "PartN" passed as a variable. That way the python script can execute the script with that variable / parameter.

How do you do that?
 
Hi. That should be easy. When you click a button on a form, it has access to the values in the current record. So, all you have to do is pass Me.PartN to the command to execute the Python script. What does that command look like?
 
Thanks @theDBguy . c:\washer\order.py (variable here). So c:\washer\order.py Me.PartN or c:\washer\order.py W41330186
 
I found this, but can't figure out how to make it work. Or where. I thought it would be a Macro, but maybe I'm wrong.
Call Shell("cmd.exe /C c:\washer\order.py", vbNormalFocus)
 
I found this, but can't figure out how to make it work. Or where. I thought it would be a Macro, but maybe I'm wrong.
Call Shell("cmd.exe /C c:\washer\order.py", vbNormalFocus)
In the Click event of your button, select Event Procedure and try this.
Code:
Call Shell("cmd.exe /C c:\washer\order.py " & Me.PartN, vbNormalFocus)
 
In the Click event of your button, select Event Procedure and try this.
Code:
Call Shell("cmd.exe /C c:\washer\order.py " & Me.PartN, vbNormalFocus)


Not sure what I'm doing wrong.

1639327366402.png

1639327304287.png
 
Are you sure they were not using 'cmd' in the general use of the term? In other words, if the file you wish to execute is Python.exe, then the Shell command would be Shell("Python.exe"), not Shell("cmd.exe"). Is the command to execute a Python file cmd.exe?
 
Are you sure they were not using 'cmd' in the general use of the term? In other words, if the file you wish to execute is Python.exe, then the Shell command would be Shell("Python.exe"), not Shell("cmd.exe"). Is the command to execute a Python file cmd.exe?

I want to run the python script here: c:\washer\order.py with the me.partN
 

Users who are viewing this thread

Back
Top Bottom