What I am trying to do: when I type a name in FieldID (combobox) and it is not in the there I click the button. As i still have the text I was typing in the combobox I want for the code to check if the FieldID is not empty and not equal to the value in FieldName in tblMoreFields which is string. If not then open the frmMoreFields form with text I started typing copied to the FieName of that form
It works for the If and Else part but errors on the Elseif statement.
What is wrong with the code/

It works for the If and Else part but errors on the Elseif statement.
Code:
Private Sub AddField_Click()
If IsNull(Me.FieldID) Then '
DoCmd.OpenForm "frmSomeFields", , , acDialog, acFormAdd
Me.FieldID.SetFocus
ElseIf Not IsNull(Me.FieldID) Then
Dim FN As String
FN = Str(Me.FieldID.Value)
If FN <> "tblMoreFields!FieldName" Then
DoCmd.OpenForm "frmMoreFields", , , "[FieldName] = " & FN, , acDialog
End If
Else
DoCmd.OpenForm "frmMoreFields", , , "[FieldID] = " & Me![FieldID], , acDialog
Me.FieldID.SetFocus
End If
End Sub
What is wrong with the code/

Last edited: