Unused forms/objects MS Access - ms-access

Is there any way I can identify unused forms/reports/queries in a compiled Access (2003) project?
Edit : There is no check for unused objects menu item in my database window.
AccessContextMenu http://f.imagehost.org/0551/AcessContextMenu.jpg

Yes, in the Database window, right click on the object (form/report/etc) and select "Object Dependencies". If it doesn't show up any where, it probably isn't used.
Although that doesn't tell you if it is called in VBA code somewhere. However you can almost totally eliminate that possibility by doing a search for the object name when viewing the VBA and make sure that you have "Current Project" selected instead of "Current Module". It doesn't prevent some evil coder from string concatenating the object name together somewhere; but it's unlikely.

Try SpeedFerret over anything from fms (it has add'l features that will probably be useful to you as a developer, and it supports .mde files).
A demo can be obtained here:
http://www.moshannon.com/downloads.html
Other useful MSAccess utitlities:
http://www.granite.ab.ca/access/thirdparty.htm

Related

Changing a value in a .config file based on a user's selection in an InstallShield 2013 install

Sorry - I'm a total newbie with InstallShield. I've inherited an InstallShield 2013 project that presents the user with a dialog that let's the user select a SQL Server and based on their selection sets a value in a config file. That's not working, so I opened the project in IS and looked in the Text File Changes under System Configuration and there's nothing there that would do this. So how do I figure out where this is happening (or not happening in my case), and then how do I get it to work? I need to set both data source and initial catalog in a file called server.config.
So how do I determine what the user selected and then save that in this file? It looks like I can set up a Text File Change, but how do I access the values selected by the user? And how can I figure out where the "code" is that is supposed to be doing this?
Thanks,
Ben
I would try to track this from the dialog and controls in question, or by following the value through a verbose log. Since you say it doesn't work today, there will probably be an interruption in the flow I describe below, and since you don't know the full state of the installation project, it may be hard to identify. So search from what you know.
Top down: what gets configured
First, find the dialog that you fill out as a user making the selection. Then figure out the property that the particular control is associated with. Now you've got a thread; pull on it.
Search in the direct editor for references to the property. If the property is named MYCONFIG search for just that: MYCONFIG. You'll probably find some sort of use that looks like [MYCONFIG] instead, which is typically a format string specifying to use the value of MYCONFIG. You may also have to search all the files related to your project, as Custom Action implementations can be code stored outside of your InstallShield project.
The use may be in a ControlEvent, CustomAction, or some other table. If it's in a ControlEvent, it may be used to set another property. Ditto if it's in a CustomAction that sets properties (type 51) which may be easier to understand in the Custom Actions and Sequences view. In that case, also search for the property that gets set.
If you find it in a table like ISSearchReplace* or ISXml*, or IniFile, it's probably part of the Text Files Changes, XML File Changes, or INI File Changes, and that view should make it easier to understand.
Maybe that thread dead-ends somewhere. A property gets set, but never referenced. So try to search from the other end.
Bottom up: what gets written
If there are text file changes, xml file changes, ini file changes, or custom actions that reference the file you need updated, see where they get their information. Try to follow it back. If they're well written, you should be able to identify the property (noting that one called CustomActionData comes from a property matching the name of the custom action it's used in), and then trace that further back using the same ideas as above, but in the other direction.
Where's the problem?
If the threads don't connect, that's probably the problem. It's also possible that a custom action lacks permissions but doesn't reports a failure, or that the file name or path got misconfigured somewhere along the way. Look for small things like that if things look like they should work but don't.
It turns out that I misunderstood the problem and the project was never set up to change that value, so all I had to do was set up a Text File Change and it works perfectly. Thanks #Michael Urman for the thorough response - I really appreciate it!

OpenFile Dialog MS Access 2010

I followed the suggestion by Cody Gray about halfway down the page in this thread but I'm having no luck.
Unless I'm missing something, this is supposed to allow me to navigate from Access, using the Windows API Dialog Box, to the relevant folder and open a file, no? I'm trying to open a Word doc which has a Mail Merge coming back to the same Access Db. I needed the dialog because there are multiple files that may be selected at different times.
I added all the suggested code and while the process runs without error, when I get to the final step, the selected file doesn't open. Nothing happens.
I realize this is not much help without an error message. Any thoughts nonetheless?
As I understand the situation, you have code which uses a string variable named strFileToOpen to hold the path to a Ms Word document. And now you want to open that file in Word.
You can use the FollowHyperlink method.
Application.FollowHyperlink strFileToOpen
Look at the Access help topic for that method. It offers other options you may wish to use.
Also I suggest you look at the help topic for FileDialog Object. It is simpler than the Windows APi method in the code you linked.

Change focus of SQL Server Management Studio

Day # 2 of SQL -
I am trying to run a function that I made yesterday, but SMSS is looking at the "Master" database and not my "Metrics" database so it won't run - it says "Invalid Object Name".
I know this is a simple question, but I'm not even sure what the correct term is. Do I need to change my "scope"? My "focus"? My "active database"? Not sure how to look this up on Google.
Add the line USE Metrics before your function call.
You can also change the database by using the dropdown list on the toolbar in the top left of Management Studio.
And of course, you can also fully qualify your call like this:
SELECT Metrics.dbo.splitstringcomma()
Adding USE YourDatabaseName at the start of all your scripts is a good habit to get into. That's my own preference.
On the SQL Editor Toolbar you have the option to change the available database.
HolTestDB in this example is the current database
Read more from: http://msdn.microsoft.com/en-us/library/ms177264.aspx

What is the correct "Document Name" of an Access ADP/MDB to use in the GetObject("Document Name") call?

According to http://support.microsoft.com/kb/288902/en-us
You can attach to a specific instance
if you know the name of an open
document in that instance. For
example, if an instance of Excel is
running with an open workbook named
Book2, the following code attaches
successfully to that instance even if
it is not the earliest instance that
was launched:
Set xlApp = GetObject("Book2").Application
Th example works for Excel, mainly because the "Document Name" is nearly the same as the filename. I need to get this to work for Access.
I have users running multiple instances of different Access Applications (.ADP) and I need to get one with a specific name. I do NOT know the complete filepath, otherwise I could do a simple
Set app = GetObject("c:\my\app\myapp.adp", "Access.Application")
Currently, I go with calling
Set app = GetObject(, "Access.Application")
and check the returned Application.Name. If it's good, I use it to call some functions on it, if not it fails. I have heard about the Running Objects Table, but since I have to get the object inside a VBScript, it's a bit too much API-calls.
Bottom Line:
What is the correct "Document Name" of an Access ADP to use in the GetObject("Document Name") call and what type of object does it return?
Coming back to this question because #phoog posted an answer, it occurs to me that since Access can have only one database open at a time, you'd need to look at each instance of Access and check its CurrentDB.Name. Now, with an ADP, I don't know what you'd check instead, but perhaps it's CurrentProject.Path.
I don't believe any of that actually addresses the original question, which seems to want to find the instance with just the filename, but I don't think that even if that worked it would be a good idea. You could easily have independent Access apps that return the same application name and filename but are stored in different locations in the file system.
You probably want to read this: http://support.microsoft.com/kb/147816
Unfortunately, it looks like "Document Name" has to be the mdb file, so if you don't know the file path, you're not going to be able to use "Document Name".
In addition to the fact that Excel can have multiple documents per instance, Excel also prevents you from opening two documents with the same name, even if they are in different folders and you are opening them in different instances of Excel.
On the other hand (to address David-W-Fenton's comment), Access does allow you to open multiple instances of the same database (not to mention different databases with the same name), as long as you don't open any instance in exclusive mode.
This is further evidence that the way Excel registers its documents in the ROT is very different from the way Access does so.

create a customised openFileDialog

i have an access program which i have been working on and i want to create a openFileDialog which will show specific folders and files. For e.g. when you click a button, instead of having the dialog showing all the folders and files, it will be given a parameter (folder name) and it will show only that folder. i am trying to achieve something similar to the windows search engine. the reason is that, my program has a folder which contains around 1000 sub folders which contain a documents. each subfolder has the same name as the document it contains. therefore, what i an trying to achieve is that from my Access Form, the user can click a button, and a dialog will pop up showing only the folder which contains the document the user is working on.
is this possible.
i would really appreciate your help thank you
Do you mean you want OpenFileDialog to start in a specific folder?
You can do it like this:
OpenFileDialog MyOpenFileDialog = new OpenFileDialog();
MyOpenFileDialog.InitialDirectory = "C:\Path\To\My\Selected\Subfolder" ;
MyOpenFileDialog.ShowDialog()
Access provides Application.FileDialog. If you want to use the ENUM for the dialog type, you'll have to add a reference to the Office Object library, but if you try to use the enum you'll get prompted and Access will add the reference for you. It's not much use, though, as it can otherwise be used quite easily with object variables instead of strongly-typed variables.
To learn how to use it, open the Immediate Window (Ctrl-G), type Application.FileDialog, and hit F1. That explains the basics.
For what it's worth, I was using Windows API code from the Access Developers Handbook before the Application.FileDialog was introduced (with A2002), so I continue to use that. I am pretty sure the functionality is identical, though Application.FileDialog probably has a spiffier interface (I don't know -- I don't use it!).