Command() returns empty (1 Viewer)

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Hi, I am opening an mdb file with the command line argument but Command() in StartApp function returns empty. StartApp is called via the AutoExec macro.

I have 2 separate TestDatabase.mdb files at separate locations. One is with the release folder with no command-line argument other with the development folder with command line argument "....\Database\TestDatabase.mdb /cmd Test"

If I open only development database, the argument is returned as Test. (Works fine)
The issue is when I open the release database first, then I open development. CommandLineArguments is returned as Empty here for dev database.(Problem)

I need to know what could be the possible reasons for ignoring the command line argument.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:13
Joined
Feb 19, 2002
Messages
43,346
I have never done this. Is there a difference in behavior depending on whether the database is already opened or if Access is opened to some other application?
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
There should not be. In this case, these are two separate databases and we should be able to open both.
I am not sure what is the difference here.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
There should not be. In this case, these are two separate databases and we should be able to open both.
I am not sure what is the difference here.
Hi. According to this documentation, the /cmd argument is part of the client environment. I guess it's not application specific.
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Thanks for the reply, To verify this, I open the first database with same command argument "Test". I was hoping that the second database will return the command line argument right. But no, it still returns empty.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:13
Joined
Feb 19, 2002
Messages
43,346
Does the second database work correctly if you open it first?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
Thanks for the reply, To verify this, I open the first database with same command argument "Test". I was hoping that the second database will return the command line argument right. But no, it still returns empty.
Hi. When you did this, did you leave the first database open when you opened the second database? I just tried it by opening Access with a /cmd switch and then opened a database with it, and they both returned the argument I passed to Access when I first opened it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:13
Joined
Feb 28, 2001
Messages
27,222
It may also make a difference in how you opened them. In the scenario you describe (having two DBs open at once) you can have done one of two things:

1. Open the 1st DB. From the File tab , Open the 2nd DB.

2. Open the 1st DB. Minimize that DB's window. Double-click the app icon to launch the 2nd DB.

In the first case, they are in the same environment, no doubt.

In the second case, I am not certain that they have exactly the same environment. They are part of the same session, certainly, and memory-wise, there is probably still only one copy of MSACCESS.EXE in memory. Windows CAN share .EXE image pure sections (or if you prefer, code sections).

I am not certain of the issue of the impure (local process data) section of that second situation. I'm not sure that the second scenario doesn't involve two processes from the same user. The first case clearly has one session opening a utility that can open two files at once but the question in my mind is where the environments split. Is there a separate child process and if so, what part of the user session does it share vs. which part gets replicated to the new child process?

This is a bit of an esoteric ramble, but to me it makes a big difference in what the two DBs can see as their environment.
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Hi. When you did this, did you leave the first database open when you opened the second database? I just tried it by opening Access with a /cmd switch and then opened a database with it, and they both returned the argument I passed to Access when I first opened it.


Yes, I left the first database open and opened second.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
Yes, I left the first database open and opened second.
Okay, thanks for the confirmation. So, I gave it another try. I created two dbs. I opened db1 with a /cmd switch and then opened db2 without. Since I see two Access icons on the Task Bar, I imagine this is what Doc was saying, that the two files have separate environments. db1 shows the correct result when I issue the Command() function in the Immediate Window and db2 shows empty. Then, I closed both dbs and opened db2 first and then opened db1 with a /cmd switch. db2 still shows empty and db1 shows the value I passed as argument. :confused:
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Okay, thanks for the confirmation. So, I gave it another try. I created two dbs. I opened db1 with a /cmd switch and then opened db2 without. Since I see two Access icons on the Task Bar, I imagine this is what Doc was saying, that the two files have separate environments. db1 shows the correct result when I issue the Command() function in the Immediate Window and db2 shows empty. Then, I closed both dbs and opened db2 first and then opened db1 with a /cmd switch. db2 still shows empty and db1 shows the value I passed as argument. :confused:

My scenario is db1 with no args, db2 with args.
open db2 first, keep it open, open db1 (works fine)
open db1 first, keep it open, open db2 (command returns empty)

Just to clarify, I am opening the db1 by double-clicking the mdb file and for db2, I am clicking the shortcut (a shortcut for the mbd, thru which I am passing the argument). if that makes any difference.
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
It may also make a difference in how you opened them. In the scenario you describe (having two DBs open at once) you can have done one of two things:

1. Open the 1st DB. From the File tab , Open the 2nd DB.

2. Open the 1st DB. Minimize that DB's window. Double-click the app icon to launch the 2nd DB.

In the first case, they are in the same environment, no doubt.

In the second case, I am not certain that they have exactly the same environment. They are part of the same session, certainly, and memory-wise, there is probably still only one copy of MSACCESS.EXE in memory. Windows CAN share .EXE image pure sections (or if you prefer, code sections).

I am not certain of the issue of the impure (local process data) section of that second situation. I'm not sure that the second scenario doesn't involve two processes from the same user. The first case clearly has one session opening a utility that can open two files at once but the question in my mind is where the environments split. Is there a separate child process and if so, what part of the user session does it share vs. which part gets replicated to the new child process?

This is a bit of an esoteric ramble, but to me it makes a big difference in what the two DBs can see as their environment.

Thanks for the explanation. Looks like I need to dig more into it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
My scenario is db1 with no args, db2 with args.
open db2 first, keep it open, open db1 (works fine)
open db1 first, keep it open, open db2 (command returns empty)

Just to clarify, I am opening the db1 by double-clicking the mdb file and for db2, I am clicking the shortcut (a shortcut for the mbd, thru which I am passing the argument). if that makes any difference.
Right. In the scenario I posted above, I did your second scenario and still got something from the command line argument. In other words, I double clicked on db1, no argument, command() function is empty. Then, I double clicked on a shortcut with a /cmd switch to open db2 and the command() function returned "test," which was the argument I passed in the shortcut.
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Right. In the scenario I posted above, I did your second scenario and still got something from the command line argument. In other words, I double clicked on db1, no argument, command() function is empty. Then, I double clicked on a shortcut with a /cmd switch to open db2 and the command() function returned "test," which was the argument I passed in the shortcut.

Thanks. Seems, it's working for you.
I need to find out where wrong I am doing.

Are you using AutoExec macro to call the function where you are checking command() return?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
Thanks. Seems, it's working for you.
I need to find out where wrong I am doing.

Are you using AutoExec macro to call the function where you are checking command() return?
Hi. No, I simply go to the Immediate Window and enter
Code:
?command()
Again, this produces nothing/empty when I simply opened the db file, but it produces "test" when I open another db using a shortcut with the /cmd switch in it.


PS. Just to be extra clear, I created two empty db files (db1 and db2). These dbs don't have anything in them at all. I then created a shortcut to open db2 with a /cmd switch. So, when I double-click db1 and then double-click on the shortcut, I get both dbs to open at the same time. When I go to the Immediate Window in each db and enter the above expression, I get the correct result as stated above. If I modify the shortcut to open db1 and then double-click db2 first and then the shortcut, the results are the same. Hope it makes sense...


PPS. Also, the results are still the same even if I double-click on the shortcut first and then the other db file. Cheers!
 
Last edited:

Micron

AWF VIP
Local time
Today, 06:13
Joined
Oct 20, 2018
Messages
3,478
Just to clarify, I am opening the db1 by double-clicking the mdb file and for db2, I am clicking the shortcut (a shortcut for the mbd, thru which I am passing the argument). if that makes any difference.
I helped someone with this problem recently. Was confusing because I couldn't replicate their issue, even with their downloaded db. Turns out that I took it for granted that they were creating a shortcut and putting the switch there, but they were not. They were opening one db with a shortcut but not the other and only the shortcut version worked.
EDIT
thus I'm saying the shortcut is a requirement. I believe that was stated in the documentation that I read long ago on how to use the Command function but I can't recall for sure. It's how I've always done it since, so I took it for granted that the other thread poster was doing the same thing.
 

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Hi, Thanks for all your responses.
I have attached a document with the steps to reproduce this issue.

Hope this will help to understand the problem better.
 

Attachments

  • Database opening issue.docx
    67.9 KB · Views: 31

theDBguy

I’m here to help
Staff member
Local time
Today, 03:13
Joined
Oct 29, 2018
Messages
21,493
Hi, Thanks for all your responses.
I have attached a document with the steps to reproduce this issue.

Hope this will help to understand the problem better.
Hi. Your doc didn't say how exactly you created the shortcut for db2. Can you please show us the Target property of your shortcut? Thanks.


Okay, I think I know what is wrong, but I'll wait to see the Target property of your shortcut. (Hint)
 
Last edited:

gaurpreeti5

Registered User.
Local time
Today, 03:13
Joined
Aug 5, 2019
Messages
13
Hi. Your doc didn't say how exactly you created the shortcut for db2. Can you please show us the Target property of your shortcut? Thanks.


Okay, I think I know what is wrong, but I'll wait to see the Target property of your shortcut. (Hint)


Right clicked and selected Create shortcut for database2.mdb. Right-click shortcut and select Properties. check attached document for the screenshot.

"C:\Users\hb67197\Documents\Database2.mdb /cmd test" this is the entire text in target property.
 

Attachments

  • shortcut creation.docx
    31 KB · Views: 29
Last edited:

Users who are viewing this thread

Top Bottom