473,503 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Discussion: Working with Windows' Windows (hWnd etc)

43 New Member
Thread split from Passing In Some Data to MS Access When Open Database.

ADezii,

That SaveSetting() and GetSetting does look useful to me for some applications though. I would be interested in how you put it to use.

Thanks!
Dec 16 '11 #1
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:
Expand|Select|Wrap|Line Numbers
  1. Application.hWndAccessApp
P.S. - Window's Handles are Unique Long Integers.
Dec 16 '11 #2
Sedrick
43 New Member
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?
Dec 17 '11 #3
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.
Dec 17 '11 #4
Sedrick
43 New Member
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!
Dec 21 '11 #5
NeoPa
32,557 Recognized Expert Moderator MVP
All done :-)
Dec 22 '11 #6
SoundGuy
1 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. SaveSetting "DevLabel", "Text", "LastDevID", txtTmpID.Value
The Access VBA helps says of this function:

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnGetLatestID_Click()
  2.     Dim txtID As String
  3.  
  4.     txtID = GetSetting("DevLabel", "Text", "LastDevID", "")
  5.     If txtID = Null Or txtID = "" Then
  6.         MsgBox "No device ID passed from DB, scan traveler sheet"
  7.         Me.txtIdentnummer.SetFocus
  8.     Else
  9.         Me.txtIdentnummer.Value = txtID
  10.         Me.btn_LookupDevID.SetFocus   ' probably not required
  11.         Call btn_LookupDevID_Click
  12.         DeleteSetting "DevLabel", "Text", "LastDevID"
  13.     End If
  14. 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
Dec 22 '11 #7
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.
Dec 23 '11 #8
Sedrick
43 New Member
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.
Dec 31 '11 #9

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

Similar topics

14
2031
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...
3
2027
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...
10
1702
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...
4
3584
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...
2
1249
by: abhilash12 | last post by:
hai ajax is not working in windows nt machine in nt machine status=501 so pls help me
2
2711
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...
4
4824
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...
12
1576
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
4
6673
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...
6
7580
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...
0
7203
marktang
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,...
0
7087
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...
0
7334
jinu1996
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...
1
6993
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...
1
5014
isladogs
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...
0
3168
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...
0
1514
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 ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.