First off, my apologies if this topic has previously been covered.
I am in the process of creating an A2K DB (Win XP) that will open other DBs (either on local drive, mapped drives, or UNC network path). My current goal is to open all forms from the target DB, read through the controls, and if the length of the control's property is > 0 (eliminate nulls and blanks), write the value out to a table on my local DB.
I am using the DBEngine.Worksp aces(0).OpenDat abase(DBName) method to do this, as the Access.Applicat ion is not exactly what I am looking for (DBs to be catalogued are quite large and have long startup scripts associated. Besides, I just want to peek inside, not run it).
I am able to successfully read through the forms collection, however when attempting to DoCmd.OpenForm( strFormName), it is attempting to open that element on the DB that is running the script (not the target).
My code: -
Function ScanObjects(strDBToScan As String)
-
-
On Error Resume Next
-
-
Dim objdb As Database, objDBToScan As Database
-
Dim doc As Document
-
Dim frm As Form
-
Dim strForm As String, strSQL As String
-
Dim ctl As Control
-
-
'This database
-
Set objdb = CurrentDb
-
-
'Target database
-
Set objDBToScan = DBEngine.Workspaces(0).OpenDatabase(strDBToScan)
-
-
'Purge current output table
-
objdb.Execute ("Delete * from t_output")
-
-
' Each doc printed is from remote DB, connection is successful.
-
For Each doc In objdb.Containers("Forms").Documents
-
strForm = doc.Name
-
Debug.Print "Processing " & strForm
-
-
' Line below opens the form in the calling database, not the target, as intended.
-
DoCmd.OpenForm strForm, acDesign, , , , acHidden
-
-
Set frm = Forms(strForm)
-
-
For Each ctl In frm.Controls
-
-
For Each prp In ctl.Properties
-
-
If Len(prp.Value) > 0 Then
-
Debug.Print objdb.Name & "," & strForm & "," & ctl.Name & "," & prp.Name & "," & prp.Value
-
strSQL = "Insert Into t_output (db_name, element_name, ctl_name, prop_name, prop_value, run_date) Values (" & _
-
"'" & Right(objDBToScan.Name, 255) & _
-
"','" & Left(strForm, 255) & _
-
"','" & Left(ctl.Name, 255) & _
-
"','" & Left(prp.Name, 255) & _
-
"','" & Left(prp.Value, 255) & _
-
"'," & Date & _
-
")"
-
objdb.Execute strSQL
-
Else
-
Debug.Print "--> Skipping " & ctl.Name & ", " & prp.Name & ", value of '" & prp.Value & "'"
-
End If
-
-
Next
-
-
Next
-
-
DoCmd.Close acForm, strForm, acSaveNo
-
-
Next
-
Debug.Print "Done."
-
-
Set ctl = Nothing
-
Set frm = Nothing
-
Set doc = Nothing
-
-
objDBToScan.Close
-
Set objDBToScan = Nothing
-
-
objdb.Close
-
Set objdb = Nothing
-
-
End Function
-
Thanks for any assistance that can be provided on this.
1 1533 ADezii 8,834
Recognized Expert Expert
First off, my apologies if this topic has previously been covered.
I am in the process of creating an A2K DB (Win XP) that will open other DBs (either on local drive, mapped drives, or UNC network path). My current goal is to open all forms from the target DB, read through the controls, and if the length of the control's property is > 0 (eliminate nulls and blanks), write the value out to a table on my local DB.
I am using the DBEngine.Worksp aces(0).OpenDat abase(DBName) method to do this, as the Access.Applicat ion is not exactly what I am looking for (DBs to be catalogued are quite large and have long startup scripts associated. Besides, I just want to peek inside, not run it).
I am able to successfully read through the forms collection, however when attempting to DoCmd.OpenForm( strFormName), it is attempting to open that element on the DB that is running the script (not the target).
My code: -
Function ScanObjects(strDBToScan As String)
-
-
On Error Resume Next
-
-
Dim objdb As Database, objDBToScan As Database
-
Dim doc As Document
-
Dim frm As Form
-
Dim strForm As String, strSQL As String
-
Dim ctl As Control
-
-
'This database
-
Set objdb = CurrentDb
-
-
'Target database
-
Set objDBToScan = DBEngine.Workspaces(0).OpenDatabase(strDBToScan)
-
-
'Purge current output table
-
objdb.Execute ("Delete * from t_output")
-
-
' Each doc printed is from remote DB, connection is successful.
-
For Each doc In objdb.Containers("Forms").Documents
-
strForm = doc.Name
-
Debug.Print "Processing " & strForm
-
-
' Line below opens the form in the calling database, not the target, as intended.
-
DoCmd.OpenForm strForm, acDesign, , , , acHidden
-
-
Set frm = Forms(strForm)
-
-
For Each ctl In frm.Controls
-
-
For Each prp In ctl.Properties
-
-
If Len(prp.Value) > 0 Then
-
Debug.Print objdb.Name & "," & strForm & "," & ctl.Name & "," & prp.Name & "," & prp.Value
-
strSQL = "Insert Into t_output (db_name, element_name, ctl_name, prop_name, prop_value, run_date) Values (" & _
-
"'" & Right(objDBToScan.Name, 255) & _
-
"','" & Left(strForm, 255) & _
-
"','" & Left(ctl.Name, 255) & _
-
"','" & Left(prp.Name, 255) & _
-
"','" & Left(prp.Value, 255) & _
-
"'," & Date & _
-
")"
-
objdb.Execute strSQL
-
Else
-
Debug.Print "--> Skipping " & ctl.Name & ", " & prp.Name & ", value of '" & prp.Value & "'"
-
End If
-
-
Next
-
-
Next
-
-
DoCmd.Close acForm, strForm, acSaveNo
-
-
Next
-
Debug.Print "Done."
-
-
Set ctl = Nothing
-
Set frm = Nothing
-
Set doc = Nothing
-
-
objDBToScan.Close
-
Set objDBToScan = Nothing
-
-
objdb.Close
-
Set objdb = Nothing
-
-
End Function
-
Thanks for any assistance that can be provided on this.
I think it would be advisable to go the Automation route - it may be the only way to go. The following code example opens a Microsoft Access database from another application through Automation and then opens a form in that database. This is just a subset of the code you will need, but it should point you in the right direction: - ' Include the following in Declarations section of module.
-
Dim appAccess As Access.Application
-
-
Dim strDB as String
-
-
' Initialize string to database path.
-
Const strConPathToExtDB = "C:\Test\"
-
-
strDB = strConPathToExtDB & "TestDatabase.mdb"
-
-
' Create new instance of Microsoft Access.
-
Set appAccess = CreateObject("Access.Application")
-
-
' Open database in Microsoft Access window.
-
appAccess.OpenCurrentDatabase strDB
-
-
' Open Test form.
-
appAccess.DoCmd.OpenForm "frmTest"
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I double-checked the path to my error log. It is in
/var/www/logs/php_error_log
Thanks. :)
-Wayne Stevenson
|
by: Arno R |
last post by:
Hi all
In another thread I had problems changing db.props
Another problem I encountered while testing this: db corrupt
When I deleted db.props through code in a loop I could not start the db again ... @#$%$
Warning: Don't just try following code on any existing db. Make sure there is a copy! (I did ...)
To test I created a NEW db in A2000 and just set some properties (menu StartUpOptions)
Props like: AppTitle, StartUpForm,...
|
by: Brent |
last post by:
I have just installed Office 2003 and Visual Studio Tools for Office 2003,
including the Developer Extensions for Access. I kept my Access 2000/MOD
installation intact (I hope), installed Access 2003 and upgraded all the
other Office apps. I have all updates/service packs installed including Jet
SP8. OS is XP Pro.
I have a repeatable situation where opening a report with code will cause
any mdb to crash every time. The following is one...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
|
by: Wolfgang Kreuzer |
last post by:
Hello all,
I am converting an Axs 2.0 application to a2k (I know A2K is not the
most current version but Axs 2.0 support ended and A2K is supported in
our company amd on every PC).
The form is part of an access projcet (ADP) and runs against SQL
Server 2000.
I have an bound form in endless view which contains a header with a
combobox. This combobox is bound to an access query and shall allow to
| |
by: Deano |
last post by:
Apparently you can only do this with one value i.e Call
MyAssetLocationZoom(Me!txtLocation, "Amend data")
This runs;
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)
On Error GoTo err_zoom
strFormName = formName
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) : base(message){}
public FtpException(string message, Exception innerException) :
base(message,innerException){}
|
by: Reggie |
last post by:
Hi and TIA. I developed several A2K dbs which are now being run on my
clients computer which have been upgraded to Access 03. I'm not sure
exactly what they mean but of you know or could point me in a direction
to find info on how to prevent and/or fix the db's so that these
message don't pop up when the app is started. Error messages below:
1. Microsoft Jet 4.0 service pack 8 must be installed to block unsafe
expressions without...
|
by: Paul Brady |
last post by:
I volunteer at a youth ministry agency and help them with their
student database. They have two computers, both running Windows XP.
Both have Office 2002 installed without Access, except that Computer A
had A97. They wanted both computers to be able to use the database,
stored on Computer A. I can't get them to do that, and it seems to be
a network problem.
I installed A2K on each computer, putting it in a special
directory which I...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |