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

Passing In Some Data to MS Access When Open Database

P: 43
I have two different databases. Both have initial login forms set up that is executed from the startup form. The first database can open the second when a button is clicked on the menu.

I would like to be able to pass in the UserID from the first database to the second when that button is clicked, bypassing the login form in the second and using the UserID there in the second.

I have looked at Interprocess Communications a little bit but have not seen any examples of how this might be done with one Access database calling up another.

I do not want to create a database object of the second database in the first in order to write a value to a table, nor write to a temporary file unless there is some way to confirm that there was not a second user also opening it at the same time. Possibly, along this line of thought, I could somehow get the process ID of the second database when opened by the first and from the first, which is still running, write that process ID and the UserID to a table or temporary txt file; then have the second database identify it's own process ID and match it to that specific record to get the UserID.

Any ideas? Thanks in advance for your input!
Dec 14 '11 #1

✓ answered by NeoPa

You should find all you need in Invoking a Database From the Command Line. It includes an example of passing string data to the database and this is explained more fully in How to use command-line switches in Microsoft Access.

Share this Question
Share on Google+
8 Replies


ADezii
Expert 5K+
P: 8,638
How, exactly, are you 'Opening' the 2nd Database?
Dec 14 '11 #2

P: 43
Using the Shell command, something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2.     stDBName = """C:\SomePath\db2.mdb"""
  3.     stAppName = "Msaccess.exe " & stDBName 
  4.     Call Shell(stAppName, vbNormalFocus)
  5.  
Dec 14 '11 #3

ADezii
Expert 5K+
P: 8,638
There is one little Trick that I use when passing Data from one 'Office Component' to another and that is to use the System Registry. I'll write the Data from the Calling Application (Access in your case), then read it from the Receiving Application (also Access). The beauty and simplicity of this approach is that, since you are dealing with Office Components, you can use the built-in SaveSetting() Statement and GetSetting() Function to accomplish this. If you are interested, let me know and I'll show you how it can be done.
Dec 14 '11 #4

NeoPa
Expert Mod 15k+
P: 31,494
You should find all you need in Invoking a Database From the Command Line. It includes an example of passing string data to the database and this is explained more fully in How to use command-line switches in Microsoft Access.
Dec 15 '11 #5

P: 43
The only problem with this approach I think is that potentially two simultaneous calls from two different users would tend to overwrite each other, right? How would the called database know which one to use?

I understand that the Shell command returns the task ID of the called program. Is this the same as the process ID in the Windows Kernel? If I could call the Kernel then from the called database to identify the current process ID I could match up which is which.
Dec 16 '11 #6

P: 43
NeoPa,

Thanks! That /cmd option with the "Command" statement should do the job very well!
Dec 16 '11 #7

NeoPa
Expert Mod 15k+
P: 31,494
I expect so. If not, there is more in that article you may find pertinent to your problem.
Dec 16 '11 #8

NeoPa
Expert Mod 15k+
P: 31,494
As requested the other matters have been split into a separate thread Discussion: Working with Windows' Windows (hWnd etc).
Dec 22 '11 #9

Post your reply

Sign in to post your reply or Sign up for a free account.