T
Terry B via AccessMonster.com
On my form I have a combo box which lists employees.
I have set the Double Click event of the combo box to open the Employee form
providing the ability to add an employee if it does not appear in the list.
I currently have the Employee form opening to a new record.
What Im trying to do is modify my current code with a little intelligence.
If the Combo box is empty on Dbl Click....Open to a new record.
If the Combo box already contains an employee on Dbl Click....Open to that
employee.
This is my current 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 "frmEmployees", , , , , 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
Thanks!
I have set the Double Click event of the combo box to open the Employee form
providing the ability to add an employee if it does not appear in the list.
I currently have the Employee form opening to a new record.
What Im trying to do is modify my current code with a little intelligence.
If the Combo box is empty on Dbl Click....Open to a new record.
If the Combo box already contains an employee on Dbl Click....Open to that
employee.
This is my current 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 "frmEmployees", , , , , 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
Thanks!