Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open Form In An External Database

19 views
Skip to first unread message

Al Aston

unread,
Jul 29, 2002, 8:54:30 PM7/29/02
to
I'm trying to open a form in another database. Thanks to Bob Hall, I can
open a form by calling the form's Open event in a module in the library
database. This works, but the second database stays open until the main
database closes. Is there a way to close the second DB when the called form
closes? (When I'm done, a large system will be broken into 5 or 6, and each
of those will grow quickly, which will be a lot of overhead if they are all
open at once.)

I've also been looking at Dev Ashish's terrific site, and came across this:
http://www.mvps.org/access/forms/frm0034.htm
Everything works step-by-step from the calling form and into the module, but
fails on the line:
".DoCmd.OpenForm strForm, intView", where the error message is "Error#:
2046 The command or action 'OpenForm" isn't available now."

Any ideas from the gurus?

Al Aston

Lyle Fairfield

unread,
Jul 29, 2002, 10:07:22 PM7/29/02
to
AC97 forms are fully exposable, and probably this could be modified for 2K and
XP:

Option Compare Database
Option Explicit
Const strExposed As String = "Attribute VB_Exposed = True" & vbCrLf
Const strStartModule = "CodeBehindForm"

Sub ExposeForm(strFormName)
Dim strFromPath As String, StrToPath As String, intFileNumber As Integer,
_
lngLen As Long, lngLeft As Long, _
strBuffer As String, strLeft As String, strRight As String

strFromPath = Environ("Temp") & "\" & strFormName & "_Original.Txt"
StrToPath = Environ("Temp") & "\" & strFormName & "_Revised.Txt"

Application.SaveAsText acForm, strFormName, strFromPath

lngLen = FileLen(strFromPath)
intFileNumber = FreeFile
Open strFromPath For Input As #intFileNumber
strBuffer = Input(lngLen, #intFileNumber)
lngLeft = InStr(strBuffer, strStartModule) + Len(strStartModule)
strLeft = left(strBuffer, lngLeft) & vbCrLf
strRight = Mid(strBuffer, lngLeft + 2)
strBuffer = strLeft & strExposed & strRight
Close #intFileNumber

intFileNumber = FreeFile
Open StrToPath For Output As #intFileNumber
Print #intFileNumber, strBuffer
Close #intFileNumber

Application.LoadFromText acForm, strFormName, StrToPath

End Sub

"Al Aston" <aas...@mindspring.com> wrote in news:ai4o5j$ptb$1
@nntp9.atl.mindspring.net:

--
Lyle

0 new messages