views:

495

answers:

2

To count Activex controls from MS-Access forms using vb.net I am using the connection as follws..

oDBEngine = oAccess.DBEngine oDB = oDBEngine.OpenDatabase(Name:=strFullFileName, Options:=False, ReadOnly:=False, Connect:="")

and Openning the forms in Design mode, as there is a user input prompt form which prevents us to run the application further if we open it in Default view.

oAccess.DoCmd.OpenForm(FormName:=objForms.Name, View:=AcFormView.acDesign)

Now the problem is:

The DataBase gets opens and along with that all the forms open up while running the application. Is there anyway we just prevent to open the database and forms, while reading the forms.

Thank you.

+1  A: 

It may suit to use a new, empty database and to import the forms programmatically. It may be possible to get a list of forms from MSysObjects (forms type is -32768).

For example:

SELECT MsysObjects.Name
FROM MsysObjects IN 'C:\docs\LTD.mdb'
WHERE MsysObjects.Type=-32768

EDIT PER COMMENT This code would go in a BLANK Access database.

strSQL = "SELECT MsysObjects.Name " _
& "FROM MsysObjects IN 'C:\docs\LTD.mdb' " _
& "WHERE MsysObjects.Type = -32768"

Set rs = CurrentDb.OpenRecordset(strSQL)

Do While Not rs.EOF
    DoCmd.TransferDatabase acImport, "Microsoft Access", _
    "C:\docs\LTD.mdb", acForm, rs![Name], rs![Name]

    'Do what ever you wish with form, then '

    DoCmd.DeleteObject acForm, rs![Name]

    rs.MoveNext
Loop
Remou
Yes, this is good way to read forms (No.Of) But I want to read each form (How many Activex Controls present).
Suman
I am suggesting that you use the sql to get a list of forms and then import them into a new database. See my edits.
Remou
+1  A: 

Sounds like an unsplit application (tables and forms/etc. in a single MDB file), and that it's being shared by multiple users. This is a disastrous scenario. See Splitting your Microsoft Access MDB into a front end and back end for all the details.

Once it's split, you'd work on an individual copy and then distribute updates to users. The point is that since version 2000 the design of an Access MDB (as opposed to the data) cannot be edited while it's open by any users.

--
David W. Fenton
David Fenton Associates

David-W-Fenton