T
tonyrusin
I'm building an app that has a combo box with different options
depending on which form the user is working from. That part is working
fine. I created a function that is supposed to open a specific form
depending on which option the user had selected. Here is my code:
---
Function CommandMenu() As String
On Error GoTo Err_CommandMenu
Dim strFormName As String
Dim strFormExpression As String
strFormName = Application.CurrentObjectName
strFormExpression = "Forms!" & strFormName & "!cboCommandMenu"
If strFormExpression = "Login" Then
DoCmd.OpenForm "frmLogin", acNormal
ElseIf strFormExpression = "CCN" Then
DoCmd.OpenForm "frmCCN", acNormal
ElseIf strFormExpression = "CCN - What's New" Then
DoCmd.OpenForm "frmCCNWhatsNew", acNormal
ElseIf strFormExpression = "CCN - Report" Then
DoCmd.OpenForm "frmCCNReportOptions", acNormal
ElseIf strFormExpression = "Database Config" Then
DoCmd.OpenForm "frmDatabaseConfig"
ElseIf strFormExpression = "DOC - Control" Then
DoCmd.OpenForm "fromDocControl"
ElseIf strFormExpression = "DOC - Library" Then
DoCmd.OpenForm "frmDocLibrary"
ElseIf strFormExpression = "DOC - What's New" Then
DoCmd.OpenForm "frmDocWhatsNew"
End If
Exit_CommandMenu:
End Function
Err_CommandMenu:
MsgBox Error$
GoTo Exit_CommandMenu
End Function
---
When I step through the process, it appears that
"strFormExpression" evaluates correctly but it doesn't find a
match when it steps through the "if" statements. Anyone know what
I'm missing here? Thanks.
- Tony
depending on which form the user is working from. That part is working
fine. I created a function that is supposed to open a specific form
depending on which option the user had selected. Here is my code:
---
Function CommandMenu() As String
On Error GoTo Err_CommandMenu
Dim strFormName As String
Dim strFormExpression As String
strFormName = Application.CurrentObjectName
strFormExpression = "Forms!" & strFormName & "!cboCommandMenu"
If strFormExpression = "Login" Then
DoCmd.OpenForm "frmLogin", acNormal
ElseIf strFormExpression = "CCN" Then
DoCmd.OpenForm "frmCCN", acNormal
ElseIf strFormExpression = "CCN - What's New" Then
DoCmd.OpenForm "frmCCNWhatsNew", acNormal
ElseIf strFormExpression = "CCN - Report" Then
DoCmd.OpenForm "frmCCNReportOptions", acNormal
ElseIf strFormExpression = "Database Config" Then
DoCmd.OpenForm "frmDatabaseConfig"
ElseIf strFormExpression = "DOC - Control" Then
DoCmd.OpenForm "fromDocControl"
ElseIf strFormExpression = "DOC - Library" Then
DoCmd.OpenForm "frmDocLibrary"
ElseIf strFormExpression = "DOC - What's New" Then
DoCmd.OpenForm "frmDocWhatsNew"
End If
Exit_CommandMenu:
End Function
Err_CommandMenu:
MsgBox Error$
GoTo Exit_CommandMenu
End Function
---
When I step through the process, it appears that
"strFormExpression" evaluates correctly but it doesn't find a
match when it steps through the "if" statements. Anyone know what
I'm missing here? Thanks.
- Tony