Solved

Using the focus to concatenate argument for the Call Shell function

Posted on 1999-01-01
8
305 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:lskelley
Comment Utility
Edited text of question
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 10

Expert Comment

by:brewdog
Comment Utility
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
Comment Utility
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
Comment Utility
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 120 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now