D
DTermani
Hello, I have a form that has a drop down box, in the drop down box there are
lists of names, if the name you want is not in the list, you double click and
it takes you to another form that allows you to input a name and user
information.
As of now it always opens a new record when double clicked, I am wanting it
to work a bit differently, but cant seem to get it right.
I want it to do this: If the name you want is not in the list, and blank,
when you double click it takes you to a new record (which it does now) but if
the name is already there, or it is in the list and selected, it takes you
directly to that record.
If it can not work that way, I am fine with it opening to the first one in
the list by default, if theres no name selected, then you can just click the
new record button on the pop up form. The main thing I need is if there is a
name in the list, then go directly to that record.
Here is the code I currently have.
lists of names, if the name you want is not in the list, you double click and
it takes you to another form that allows you to input a name and user
information.
As of now it always opens a new record when double clicked, I am wanting it
to work a bit differently, but cant seem to get it right.
I want it to do this: If the name you want is not in the list, and blank,
when you double click it takes you to a new record (which it does now) but if
the name is already there, or it is in the list and selected, it takes you
directly to that record.
If it can not work that way, I am fine with it opening to the first one in
the list by default, if theres no name selected, then you can just click the
new record button on the pop up form. The main thing I need is if there is a
name in the list, then go directly to that record.
Here is the code I currently have.
Code:
Private Sub EmployeeID_DblClick(Cancel As Integer)
On Error GoTo Err_EmployeeID_DblClick
Dim lngEmployeeID As Long
If IsNull(Me![EmployeeID]) Then
Me![EmployeeID].Text = ""
Else
lngEmployeeID = Me![EmployeeID]
Me![EmployeeID] = Null
End If
DoCmd.OpenForm "Employees", , , , , acDialog, "GotoNew"
Me![EmployeeID].Requery
If lngEmployeeID <> 0 Then Me![EmployeeID] = lngEmployeeID
Exit_EmployeeID_DblClick:
Exit Sub
Err_EmployeeID_DblClick:
MsgBox Err.Description
Resume Exit_EmployeeID_DblClick
End Sub