I have the following VB code:
Sub trial2()
Dim appAccess As Access.Application
Dim strDB As String
Dim strFormName As String
' Initialize string to database path.
strDB = "c:\AA_xx\Workplan.mdb"
' Initialize string to Form name.
strFormName = "frmWorkPlan"
Set appAccess = _
CreateObject("Access.Application"
' Open database in Microsoft Access.
appAccess.OpenCurrentDatabase strDB
' Open form
appAccess.DoCmd.OpenForm strFormName
' Modify form
Forms(strFormName).Controls("status".RowSource = "inProgress"
appAccess.DoCmd.Save acForm, strFormName
appAccess.CloseCurrentDatabase
Set appAccess = Nothing
End Sub
But when I run it, I got problem with this line:
Forms(strFormName).Controls("status".RowSource = "inProgress"
And the message is that "Microsoft Access can't fine the form 'frmWorkPlan' referred to in a macro expression or Visual Basic code".
Since I have "openForm" on the previous line, I don't understand why it doesn't work.
Thanks.
Kuan
Sub trial2()
Dim appAccess As Access.Application
Dim strDB As String
Dim strFormName As String
' Initialize string to database path.
strDB = "c:\AA_xx\Workplan.mdb"
' Initialize string to Form name.
strFormName = "frmWorkPlan"
Set appAccess = _
CreateObject("Access.Application"
' Open database in Microsoft Access.
appAccess.OpenCurrentDatabase strDB
' Open form
appAccess.DoCmd.OpenForm strFormName
' Modify form
Forms(strFormName).Controls("status".RowSource = "inProgress"
appAccess.DoCmd.Save acForm, strFormName
appAccess.CloseCurrentDatabase
Set appAccess = Nothing
End Sub
But when I run it, I got problem with this line:
Forms(strFormName).Controls("status".RowSource = "inProgress"
And the message is that "Microsoft Access can't fine the form 'frmWorkPlan' referred to in a macro expression or Visual Basic code".
Since I have "openForm" on the previous line, I don't understand why it doesn't work.
Thanks.
Kuan