Hi everyone
I am just learning VB and am trying to put some code in so that employees can be added to the combo box if they are not on the list.
I have put the code in but get an error message "Compile error: Ambigiuos name detected: ClientInputButton_Click" when I try and enter a new employee record.
The form in which the employees are added is based on a query. The control of the combo box is EmployeeID and is a field in a table called "Timesheet". I have a table called Employees with EmployeeID field as the primary key.
Below is the code I put into NotInList event procedure
Private Sub EmployeeID_NotInList(NewData As String, Response As Integer)
' Allows user to add a new employee by typing the employee's name
' in the EmployeeID combo box.
Dim intNewCustomer As Integer, strTitle As String
Dim intMsgDialog As Integer, strMsg As String
Const conClrWhite = 16777215
Const conNormal = 1
' Check if user has already selected an employee.
If IsNull(CustomerID) Then
' Display message box asking if the user wants to add a new employee.
strTitle = "Employee Not in List"
strMsg = "Do you want to add a new employee?"
intMsgDialog = vbYesNo + vbExclamation
intNewEmployee = MsgBox(strMsg, intMsgDialog, strTitle)
If intNewEmployee = vbYes Then
' Remove text user entered from the combo box and assign
' it to the EmployeeID control.
DoCmdDoMenuItem acFormBar, acEdit, acUndoField
EmployeeID.Enabled = True
EmployeeID = NewData
' Enable and move focus to EmployeeID.
EmployeeID.Enabled = True
EmployeeID.Locked = False
EmployeeID.BackColor = conClrWhite
EmployeeID.BorderStyle = conNormal
EmployeeID.SetFocus
MsgBox "Enter the new Employee's."
' Continue without displaying default error message.
Response = acDataErrAdded
Else
' Display the default error message.
Response = acDataErrAdded
End If
Else
' User has already picked an employee; display a message and undo the field.
strMsg = "To modify this customer's company name, edit the name in the "
strMsg = strMsg & "box below the EmployeeID combo box. To add a new employee, "
strMsg = strMsg & "click Undo Record on the Records menu and then type the "
strMsg = strMsg & "new employee name in the EmployeeID combo box."
MsgBox strMsg
DoCmd.DoMenuItem acFormBar, acEdit, acUndoField
' Continue without displaying default error message.
Response = acDataErrAdded
End If
End Sub
End Sub
Can anyone help me?
Thanks in advance
I am just learning VB and am trying to put some code in so that employees can be added to the combo box if they are not on the list.
I have put the code in but get an error message "Compile error: Ambigiuos name detected: ClientInputButton_Click" when I try and enter a new employee record.
The form in which the employees are added is based on a query. The control of the combo box is EmployeeID and is a field in a table called "Timesheet". I have a table called Employees with EmployeeID field as the primary key.
Below is the code I put into NotInList event procedure
Private Sub EmployeeID_NotInList(NewData As String, Response As Integer)
' Allows user to add a new employee by typing the employee's name
' in the EmployeeID combo box.
Dim intNewCustomer As Integer, strTitle As String
Dim intMsgDialog As Integer, strMsg As String
Const conClrWhite = 16777215
Const conNormal = 1
' Check if user has already selected an employee.
If IsNull(CustomerID) Then
' Display message box asking if the user wants to add a new employee.
strTitle = "Employee Not in List"
strMsg = "Do you want to add a new employee?"
intMsgDialog = vbYesNo + vbExclamation
intNewEmployee = MsgBox(strMsg, intMsgDialog, strTitle)
If intNewEmployee = vbYes Then
' Remove text user entered from the combo box and assign
' it to the EmployeeID control.
DoCmdDoMenuItem acFormBar, acEdit, acUndoField
EmployeeID.Enabled = True
EmployeeID = NewData
' Enable and move focus to EmployeeID.
EmployeeID.Enabled = True
EmployeeID.Locked = False
EmployeeID.BackColor = conClrWhite
EmployeeID.BorderStyle = conNormal
EmployeeID.SetFocus
MsgBox "Enter the new Employee's."
' Continue without displaying default error message.
Response = acDataErrAdded
Else
' Display the default error message.
Response = acDataErrAdded
End If
Else
' User has already picked an employee; display a message and undo the field.
strMsg = "To modify this customer's company name, edit the name in the "
strMsg = strMsg & "box below the EmployeeID combo box. To add a new employee, "
strMsg = strMsg & "click Undo Record on the Records menu and then type the "
strMsg = strMsg & "new employee name in the EmployeeID combo box."
MsgBox strMsg
DoCmd.DoMenuItem acFormBar, acEdit, acUndoField
' Continue without displaying default error message.
Response = acDataErrAdded
End If
End Sub
End Sub
Can anyone help me?
Thanks in advance