Form and Subform (Subform is Combo Box)

cliffsimms

Registered User.
Local time
Today, 15:12
Joined
Sep 28, 2000
Messages
18
I have a form with Employee Name, Phone and Email. The subform is the Company Name, Address, Affiliation.

The Employee Name,Phone and Email are looking at a table.

The Subform Company Name, Address and Affiliation are looking at a query. All of the fields are Combo Boxs.
What I am trying to do is allow someone type for use the drop down menu on the combo box, but when the name is not there have a messeage pop up and tell them that the name is not there they need to add it. How would I get a second button appear that allows them to click to add the name and open a form to do so. I have written some code for it. Everything works up to the point where they double click the field. A message appears stating that a nul value is trying to be placed in a variable that is not a variant value.

Here is the code

Private Sub Company_DblClick(Cancel As Integer)
On Error GoTo Err_Company_DblClick

Dim lngCompany As Long

If IsNull(Me![Company]) Then
Me![Company].Text = ""
Else
lngCompany = Me![Company]
Me![Company] = Null
End If
DoCmd.OpenForm "frmAddCompany", , , , , acDialog, "GotoNew"
Me![Company].Requery
If lngCompany <> 0 Then Me![Company] = lngCompany

Exit_Company_DblClick:
Exit Sub

Err_Company_DblClick:
MsgBox Err.Description
Resume Exit_Company_DblClick

End Sub

The code below works but could I add a buttone that says Add and opens a FOrm automatically?

Private Sub Company_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
 

Users who are viewing this thread

Back
Top Bottom