How to prevent to open a MS Access Database while reading data from forms

孤者浪人 提交于 2019-12-25 01:31:04

问题


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:


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.




回答2:


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


来源:https://stackoverflow.com/questions/427436/how-to-prevent-to-open-a-ms-access-database-while-reading-data-from-forms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!