8 3738 ADezii 8,834
Recognized Expert Expert @Sedrick:
Would passing the Windows Handle of the Calling Access Main Window do the trick? This can be accomplished via: - Application.hWndAccessApp
P.S. - Window's Handles are Unique Long Integers.
ADezii,
Now you've got me thinking. (That could be dangerous).
I've never used Application.hWndAccessApp. In doing a little bit of checking, I can see it provides a unique identifier of the main Access window but I'm not sure yet how the called database could use it to determine the UserID in the calling database.
It seems like there are times when it would be handy to be able to dynamically communicate between two database instances. I know that you can create a new instance object of another database from one database, but is is possible at all to use the "Set" command, for example in the called database to create a reference to the existing calling database object? Seems like if you could somehow get that, you would have everything currently going on in the calling database available to the called database. You could read the values of a public variable, for example that would contain the UserID.
I tried this but all I could come up with was creating a new instance of the calling database where of course you cannot get at any existing objects or variables in the calling database object.
Are there any services available to MS Access, possibly using Application.hWndAccessApp to do this?
NeoPa 32,557
Recognized Expert Moderator MVP Application Automation may help with that. Not specifically, but it may provide an outline understanding. I would look into GetObject() if I were looking to do what you seem to be.
PS. I should mention that, from the original question, this appears to be over-complicating things. What you need is perfectly adequately provided by passing a parameter value into the database as you open it. Not that it's not interesting in its own right of course, but unless I misunderstand your original requirement (which is the topic of this particular thread), it is not relevant here (I'm assuming you're not looking for a Windows solution for what is already available from Access). Let me know if this is a discussion you'd like to continue separately and I'll split this into a new thread for you. It is interesting after all.
Sorry for the delay. Yes if you could break that into another thread, I'd be interested in discussing it. Thank you for pointing out the solution to the current problem - /cmd option from the command line. That should work perfect!
This other discussion on application automation seems quite valuable to me for future applications.
Thanks!
NeoPa 32,557
Recognized Expert Moderator MVP
If you're still interested in an example of SaveSetting() and GetSetting(), I spent an hour or so today figuring out how it works and then putting it to use. I use it to communicate one piece of data between two databases, both of which are open at the same time on the same computer but which cannot (at the moment) be somehow combined into one.
In one db I have a form that presents data that is looked up based on a production order and a button click (no rocket science). The lookup and presentation of the most recent data is accomplished during the FormCurrent event. After all the fields have been filled by query results, one string is stored in the registry with this statement: - SaveSetting "DevLabel", "Text", "LastDevID", txtTmpID.Value
The Access VBA helps says of this function: - SaveSetting appname, section, key, setting
I discovered that "appname" can be any string as can "section" and "key" with "setting" being the string you want to store in the registry for later use. They just have to be the same as are used in the GetSetting function.
The user then alt-tabs over to the next database window and clicks a button which gets the data from the registry, puts it in a text field and then triggers a click event to perform the next step in the process: -
Private Sub btnGetLatestID_Click()
-
Dim txtID As String
-
-
txtID = GetSetting("DevLabel", "Text", "LastDevID", "")
-
If txtID = Null Or txtID = "" Then
-
MsgBox "No device ID passed from DB, scan traveler sheet"
-
Me.txtIdentnummer.SetFocus
-
Else
-
Me.txtIdentnummer.Value = txtID
-
Me.btn_LookupDevID.SetFocus ' probably not required
-
Call btn_LookupDevID_Click
-
DeleteSetting "DevLabel", "Text", "LastDevID"
-
End If
-
End Sub
The GetSetting returns the string from the registry or an empty string (default) if there is no entry. After using the string I delete the entry so it can't accidentally be used again.
This probably beginner stuff but it made a huge simplification in our manufacturing process possible. I would never have known about it if I hadn't googled across this discussion.
Thanks,
--SG
NeoPa 32,557
Recognized Expert Moderator MVP
Thanks to you too, for posting what you managed to get working.
PS. Bold tags work, but don't highlight well, when used within a CODE tag block, so I'll change them to italics for you.
PPS Italics wasn't too clear either so I used underscores instead.
SoundGuy,
Glad to hear ADezii's suggestion helped in your application!
Thanks NeoPa and ADezii for all the input to my questions. Sorry haven't gotten back to this sooner.
Was looking at the GetObject function but have not had time to test it out yet. Seems like it might read standard objects but not classes created with VBA. I'm thinking about trying it with the CurrentDb.Properties members to see if it would access them.
I'm also thinking it might be possible to read data from a field on a form in the calling database from the called database. I wonder, since the form class is not created by VBA if it would allow access to the Form's Class modules. I've done some work recently involving making Subs and Variables Public in a form class module and accessing them from other forms.
Will be good to take a closer look when I get some time. I think it will come in handy in the future.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rogerclive |
last post by:
Perhaps, there is no bigger sleazy company in the entire Maple Republic
( Canada ) than Matrox Graphics Inc.
I paid $100+ through my nose circa 1999 for Matrox Millenium II and
Mystique.
It...
|
by: Ashhad Syed |
last post by:
I have turned on smartnavigation=True for some of the forms in my .NET
application. It seemed to be working fine on Windows 2000 SP4, which also has
VS 2003 installted, but when I moved the...
|
by: sp |
last post by:
The application is written in Visual Basic / .NET and working without
problems under Windows XP, Windows 2000, Windows 2003 but it isn't
working under Windows ME and Windows 98 - the computer...
|
by: tekeste |
last post by:
Hello guys. is there someone out there to tell me why TAB key is not working in windows CE mobile application in .net? I just want to move from one textbox to the next using TAB key, but it won't...
|
by: abhilash12 |
last post by:
hai
ajax is not working in windows nt machine in nt machine status=501
so pls help me
| |
by: mindspring |
last post by:
A pc that was created in MS office xp's Access 2002 has been working fine on
a windows vista Ultimate pc that has MS OFfice Vista Edition. But all of
the sudden it stopped working and gives this...
|
by: while-one |
last post by:
When I make a new website, during development I create
a new virtual domain definition (using a temporary, made-up name)
in apache's configuration, and then bounce my server.
Then, on the client...
|
by: Angkor |
last post by:
Hi All,
I am trying to pass value from a page to another page through session
variable.
session_start();
$_SESSION = $value("aid");
.....
$_SESSION has value within its original page. But
|
by: adnanjunk |
last post by:
Hi,
Having a little issue with .htaccess not working on windows server. I
have clean url's setup using the htaccess file, working fine on linux
server. I have researched for a while and found...
|
by: josequinonesii |
last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet...
Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |