Novice struggling to troubleshoot some code and looking for help. I have a form "Remake Form" and in the BeforeUpdate Event I have code to validate if a combo box is empty. It worked until I tried to add code to dropdown the combo box.
Code:Private Sub Form_BeforeUpdate(Cancel As Integer) If Len(Me.PlantLocationBox & vbNullString) = 0 Then MsgBox "Please enter the missing info" Cancel = True Me.CustomerNameButton.SetFocus Me.PlantLocationBox.SetFocus Me.PlantLocationBox.Dropdown Exit Sub End If End Sub
So if the PlantLocationBox is blank when I try to close the form, the message box pops up. I click OK and the command moves the focus to a field above the combo box (is this the correct way to get to the top of the form?). I then set the focus to the PlantLocationBox combo box. That works great, but if I add code to dropdown I get error 3021: No current record.
What am I doing wrong? What's interesting to me is if I OK the error, and just try to save again, the message box validation pops up again. If I click OK a second time, the command works correctly, and the dropdown opens.