C
Chas
Hi, I'm having trouble with the following code:
Private Sub Customer_ID_DblClick(Cancel As Integer)
Dim objAccess As Object
Dim Pathstring As String
Dim cmdForm As Object
Dim OpenedForm As Object
Dim FormName As String
Dim objColForms As Access.Forms
Dim numForms As Long
Pathstring = "c:\DB-FE\DB-FE.mdb"
Set objAccess = CreateObject("Access.Application")
Call objAccess.OpenCurrentDatabase(Pathstring, False)
Set objColForms = objAccess.Forms
numForms = objColForms.Count
FormName = "Registrant"
Set cmdForm = objAccess.DoCmd
Set OpenedForm = objColForms.Item(FormName)
Call cmdForm.OpenForm(FormName, acNormal, , "Customer_ID=" & _
objAccess.Forms.Item(FormName).Customer_ID, acFormPropertySettings, acWindowNormal)
End Sub
I have similar code working on other DBs, this particular one gives
me the following when I try to run it, from the line "Set OpenedForm = objColForms.Item(FormName)":
Run-time error '2450':
Microsoft Access can't find the form 'Registrant' referred to in a macro expression or Visual Basic code.
Thing is after it opens the Access application I can open the form from it, but it can't find it.
Private Sub Customer_ID_DblClick(Cancel As Integer)
Dim objAccess As Object
Dim Pathstring As String
Dim cmdForm As Object
Dim OpenedForm As Object
Dim FormName As String
Dim objColForms As Access.Forms
Dim numForms As Long
Pathstring = "c:\DB-FE\DB-FE.mdb"
Set objAccess = CreateObject("Access.Application")
Call objAccess.OpenCurrentDatabase(Pathstring, False)
Set objColForms = objAccess.Forms
numForms = objColForms.Count
FormName = "Registrant"
Set cmdForm = objAccess.DoCmd
Set OpenedForm = objColForms.Item(FormName)
Call cmdForm.OpenForm(FormName, acNormal, , "Customer_ID=" & _
objAccess.Forms.Item(FormName).Customer_ID, acFormPropertySettings, acWindowNormal)
End Sub
I have similar code working on other DBs, this particular one gives
me the following when I try to run it, from the line "Set OpenedForm = objColForms.Item(FormName)":
Run-time error '2450':
Microsoft Access can't find the form 'Registrant' referred to in a macro expression or Visual Basic code.
Thing is after it opens the Access application I can open the form from it, but it can't find it.