By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Help. Button: copy value from field, followed by start ext. application.

P: n/a
I want to add a button doing the following:

copying the value of a certain field (postal code)the present record
and then start an external application. How to perform the first?

Bart

Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
AA Arens wrote:
I want to add a button doing the following:

copying the value of a certain field (postal code)the present record
and then start an external application. How to perform the first?

Bart

Copying to what? To a variable?

Drag a command button to a form. Click on Events for the property sheet
of the button and in the OnClick event click the tripple button and
select Code. Now enter
Dim varCopyValue As Variant
Dim strAppToOpen
'copy value?
varCopyValue = Me.PostalCode
'open external app
strAppToOpen = "C:\Test\Test.Exe"
Shell strAppToOpen

Check out Shell for determining how the window of the app should display.

Nov 13 '05 #2

P: n/a
AA Arens wrote:
I want to add a button doing the following:

copying the value of a certain field (postal code)the present record
and then start an external application. How to perform the first?

Bart

Copying to what? To a variable?

Drag a command button to a form. Click on Events for the property sheet
of the button and in the OnClick event click the tripple button and
select Code. Now enter
Dim varCopyValue As Variant
Dim strAppToOpen
'copy value?
varCopyValue = Me.PostalCode
'open external app
strAppToOpen = "C:\Test\Test.Exe"
Shell strAppToOpen

Check out Shell for determining how the window of the app should display.

Nov 13 '05 #3

P: n/a
I want Access copies the contents of the field "postal code" (like
12345) which is part of the same form as the button i want to make, to
launch an external applicaiton. I need the copied value in the external
application.

Bart

Nov 13 '05 #4

P: n/a
I want Access copies the contents of the field "postal code" (like
12345) which is part of the same form as the button i want to make, to
launch an external applicaiton. I need the copied value in the external
application.

Bart

Nov 13 '05 #5

P: n/a
AA Arens wrote:
I want Access copies the contents of the field "postal code" (like
12345) which is part of the same form as the button i want to make, to
launch an external applicaiton. I need the copied value in the external
application.

Bart

I created a form with 2 text boxes; Text0 and Text2. In the AfterUpdate
event of Text0 I entered the following code
Me.Text0.SelStart = 0
Me.Text0.SelLength = Len(Me.Text0)
DoCmd.RunCommand acCmdCopy

When I moved to Text2 I could do an edit/paste and the value I entered
in Text0 would be filled in.

If you were in Access, you could use
DoCmd.RunCommand acCmdPaste

How you paste the value from the clipboard into an external app is
something you can do manually with a Ctrl+V or Edit/Paste from it's menu.

Use Shell to open the external app or else use one of the API calls
found at http://www.mvps.org/access.
Nov 13 '05 #6

P: n/a
AA Arens wrote:
I want Access copies the contents of the field "postal code" (like
12345) which is part of the same form as the button i want to make, to
launch an external applicaiton. I need the copied value in the external
application.

Bart

I created a form with 2 text boxes; Text0 and Text2. In the AfterUpdate
event of Text0 I entered the following code
Me.Text0.SelStart = 0
Me.Text0.SelLength = Len(Me.Text0)
DoCmd.RunCommand acCmdCopy

When I moved to Text2 I could do an edit/paste and the value I entered
in Text0 would be filled in.

If you were in Access, you could use
DoCmd.RunCommand acCmdPaste

How you paste the value from the clipboard into an external app is
something you can do manually with a Ctrl+V or Edit/Paste from it's menu.

Use Shell to open the external app or else use one of the API calls
found at http://www.mvps.org/access.
Nov 13 '05 #7

P: n/a
I get an error message: "Compile error: Method or data menmber not
found" (then SelStart is selected). I used the right control Control
Scource.
This is my script (I am aware of pasting in ext. app.):

Private Sub test_Click()
On Error GoTo Err_test_Click

Me.PostalCode.SelStart = 0
Me.PostalCode.SelLength = Len(Me.PostalCode)
DoCmd.RunCommand acCmdCopy
' DoCmd.RunCommand acCmdPaste
Dim stAppName As String
stAppName = "C:\Program Files\AutoHotkey\AutoHotkey.exe"
Call Shell(stAppName, 1)

Exit_test_Click:
Exit Sub

Err_test_Click:
MsgBox Err.Description
Resume Exit_test_Click

End Sub

Nov 13 '05 #8

P: n/a
Br
AA Arens <ba***********@gmail.com> wrote:
I get an error message: "Compile error: Method or data menmber not
found" (then SelStart is selected). I used the right control Control
Scource.
This is my script (I am aware of pasting in ext. app.):

Private Sub test_Click()
On Error GoTo Err_test_Click

Me.PostalCode.SelStart = 0
Me.PostalCode.SelLength = Len(Me.PostalCode)
DoCmd.RunCommand acCmdCopy
' DoCmd.RunCommand acCmdPaste
Dim stAppName As String
stAppName = "C:\Program Files\AutoHotkey\AutoHotkey.exe"
Call Shell(stAppName, 1)

Exit_test_Click:
Exit Sub

Err_test_Click:
MsgBox Err.Description
Resume Exit_test_Click

End Sub


Two things....

Your syntax is wrong. Use the exclamation mark (ie. Me![PostalCode]) not
the dot operator. It's good practice to use the square brackets too (you
have to if you put spaces in the control name which IMO is bad practice
anyway:)

Second, the field must have the focus before using these methods. So
your code should be.....

Me![PostalCode].Setfocus
Me![PostalCode].SelStart = 0
Me![PostalCode].SelLength = Len(Me![PostalCode])

Hope that helps.
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #9

P: n/a
After the reparaton, I now get an error message containing:

"OBject doesn't support this property or method"
(I use Access 2003)

Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.