?
Solved

Using the focus to concatenate argument for the Call Shell function

Posted on 1999-01-01
8
Medium Priority
?
322 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
  • 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
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 

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

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 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