ElseIf not working

keith267

New member
Local time
Today, 11:46
Joined
Nov 24, 2016
Messages
6
I'm using the below code to open two different forms depending on two different variables. But the ElseIf statement is not working? My form gives the selection for ProposalVersion of "Original" and "Last Update". "Original" is recognized but "Last Update" is not. Any ideas

Private Sub SearchResults_DblClick(Cancel As Integer)

Dim stFrmName As String
Dim stFrmName1 As String
Dim stLinkCriteria As String
Dim stLinkCriteria1 As String
Dim stServiceRequested As String
Dim stProposalVersion As String


stFrmName = "Proposals-no_Updates-PopUp"
stFrmName1 = "Proposals-With_Updates"

stLinkCriteria = "[ProposalNum]=" & Me![SearchResults]
stLinkCriteria1 = "[ProposalNum]=" & Me![SearchResults]
stServiceRequested = Me.SearchResults.Column(6)

stProposalVersion = Me.SearchResults.Column(10)

If stServiceRequested = "Negotiation" And stProposalVersion = "Original" Then
DoCmd.OpenForm stFrmName, , , stLinkCriteria
ElseIf stServiceRequested = "Negotiation" And stProposalVersion = "Last Update" Then
DoCmd.OpenForm stFrmName1, , , stLinkCriteria
Else
MsgBox ("something is wrong")
End If

End Sub
 
Last edited:
Have you single stepped the code to see what is in the variables?
 
Not sure how to do that
 
While looking at the code, put your cursor to the left of the left boundary and left click. A dot should appear which is a BreakPoint marker. I would suggest putting it to the left of the stFrmName = "Proposals-no_Updates-PopUp" line. Then run the form and it will stop on the Breakpoint line. You use F8 to advance one line of code at a time. When you hover the cursor over a variable, a balloon pops up to let you see what is in that variable.
 
Thank you both. Turns out I a typo in my table the one record which was a "Last Update" had "Negotiations" instead of "Negotiation".

I appreciate your help.
 
Glad you found it.

Always use Option Explicit at the top of a module. It will identify undimmed /misspelled items quickly.

Good luck.
 

Users who are viewing this thread

Back
Top Bottom