?
Solved

Using the focus to concatenate argument for the Call Shell function

Posted on 1999-01-01
8
Medium Priority
?
313 Views
Last Modified: 2012-05-04
How can I use the focus to concatenate argument for the Call Shell function?

I can use it to compare it to a string of a file
name that the focus is on a string field of a form
but I cant concatenate the return value with another
string to get it run the shell function.
I do not want to code a bunch of ifs or use a loop
to go through entries in the table that contains the
name of the file so it will run the shell function.
I need the use the name that returns from the focus
after a user pushes the command button to launch this
program and open the file passed to it by the focus,
(sort of like typing in the DOS world c:\aclt.exe filename).

below is the code that works to compare and launch the file
if the focus returns the proper filename. I have coded a
bunch of ifs to check against which file the focus returns
using this method but this is not practicle for adding
new filenames to the database.

Sub btnEditDrawing_Click()
On Error GoTo Err_btnEditDrawing_Click

    Dim stAppName As String
   
    strFileName.SetFocus
    If strFileName = "LEVELSUB.DWG" Then
        stAppName = "C:\ACLTWIN\ACLT.EXE C:\WORK\Meridien\LEVELSUB.DWG"
        Call Shell(stAppName, 1)
    End If
    If IsNull(strFileName) Then
        DoCmd.OpenForm "dglFileError", acNormal
    End If

Exit_btnEditDrawing_Click:
    Exit Sub

Err_btnEditDrawing_Click:
    MsgBox Err.Description
    Resume Exit_btnEditDrawing_Click
   
End Sub

What I want is something like this in psuedo code:
    strFileName.SetFocus
        stAppName = "C:\ACLTWIN\ACLT.EXE C:\WORK\Meridien\"&[SetFocus]
'The above should work but doesn't as something is not being translated right and I dont know what
        Call Shell(stAppName, 1)
 
0
Comment
Question by:lskelley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 10

Expert Comment

by:brewdog
ID: 1972461
How do you know which program the user wants to launch? Are they choosing from a list of programs, or . . .?

It sounds like you might want to have a list or combo box with two columns: one with a name the user will recognize, and the other with the file path. Then when they click a button to launch the app they chose in the list/combo box, you could just use the list box value in your Shell function. That would also make it easier in the future when apps are added to your database: a simple addition to the Apps table would automatically be accommodated.

Would that work in your situation?

brewdog
0
 

Author Comment

by:lskelley
ID: 1972462
No I do not want  a combo box as the user is using a form that is already displaying
the name of the file and the focus is already on the name of the file. When the button
is pressed the above code executes. My problems is trying to get the string return
from the focus to work as a concatenated string with
"C:\ACLTWIN\ACLT.EXE C:\WORK\"& here I place SetFocus which doesn't
work

0
 

Author Comment

by:lskelley
ID: 1972463
forgot to add that the only program I want to launch for this app is acltwin.exe in the
string above. The user has no choice of that, only which file it will open at run time
which comes from the focus of the filename in the form.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:lskelley
ID: 1972464
Edited text of question
0
 
LVL 10

Expert Comment

by:brewdog
ID: 1972465
I'm a little confused about one thing: you keep referring to returning the name of the file from the focus. The focus is simply where the computer is looking at this time. You can set the focus/cursor somewhere, but you can't "return" anything from the focus. How does the user tell you which file s/he wants. Below, I'm making the assumption that the user has entered the file name in a text box; the syntax would be the same if you were using list/combo boxes.

So the user types/chooses the file name (not the app) and you need to concatenate that file name with the file path to the app and then the directory, etc.? Is it always going to come from the same directory? If so, you could do this:

strAppName = "C:\ACLTWIN\ACLT.EXE C:\WORK\Meridien\" & [TheNameOfYourTextBox]

then do your shell function. Would that work?

brewdog
0
 

Author Comment

by:lskelley
ID: 1972466
I obviously was under the mistaken impression that the focus was returning
the the information now from reading your comments I see that what I need
to talk about is the value strFileName is returning.

The user is not necessarily typing in the file name it could already be put
there from the table the form is working on. If you use the line of code such
as you have shown, (modified to fit my app):

strAppName="C:\ACLTWIN\ACLT.EXE C:\WORK\Meridien\" & [strFilename]

It works!

Thank you!

It shows me that I need to improve my communication skills to where I need to
understand the problem thoroughly before posting such a question!

If you submit it as an answer I will let you have the points as this was
giving me a headache and I should known better! (It was a late night and
I was getting deperate to show this database to someone).
0
 

Author Comment

by:lskelley
ID: 1972467
Oh by the way can you tell me where to find out how to give you the points and lock
this question I am brand new to this message board.

Thanks!

0
 
LVL 10

Accepted Solution

by:
brewdog earned 480 total points
ID: 1972468
Now that I've submitted an answer, you can simply accept it (and grade it) and I'll get the points. Thank *you*, and I'm glad your problem is solved.

brewdog
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question