spalmateer
Registered User.
- Local time
- Today, 13:00
- Joined
- Dec 5, 2000
- Messages
- 46
Hi,
I have a combo box on my form that has a list of builders. I have limited the input to the list but I would like to have the user be able to add additions to the list without having to leave the form. For example if the user types something that is not on the list, a message box will appear asking if the user would like to add 'this value' to the list. I've attempted to add code similiar to this (but with different names) without any luck-
Private Sub Builders_NotInList(NewData As String, Response As Integer)
Dim strMessage As String
Dim dbsContacts As Database
Dim rstTypes As DAO.Recordset
strMessage = "Are you sure you want to add '" & NewData & "' to the list of contacts?"
If Confirm(strMessage) Then
Set dbsContacts = CurrentDb
Set rstTypes = dbsContacts.OpenRecordset("Contact Types")
rstTypes.AddNew
rstTypes!ContactType = NewData
rstTypes.Update
Response = acDataErrAdded
Else
Response = asDataErrDisplay
End If
End Sub
This code above references the Confirm function which is:
Public Function Confirm(strMessage As String) As Boolean
Dim bytChoice As Byte
bytChoice = MsgBox(strMessage, vbQuestion + vbOKCancel, "ACE")
If bytChoice = vbOK Then
Confirm = True
Else
Confirm = False
End If
End Function
My combo box feeds off the table tblBuildersLookup. My form name is frmCustInfMain and the combobox is Builders.
I'm horrible with VB so I might just have the form and table references wrong. Thanks in advance for any help!
Scott
I have a combo box on my form that has a list of builders. I have limited the input to the list but I would like to have the user be able to add additions to the list without having to leave the form. For example if the user types something that is not on the list, a message box will appear asking if the user would like to add 'this value' to the list. I've attempted to add code similiar to this (but with different names) without any luck-
Private Sub Builders_NotInList(NewData As String, Response As Integer)
Dim strMessage As String
Dim dbsContacts As Database
Dim rstTypes As DAO.Recordset
strMessage = "Are you sure you want to add '" & NewData & "' to the list of contacts?"
If Confirm(strMessage) Then
Set dbsContacts = CurrentDb
Set rstTypes = dbsContacts.OpenRecordset("Contact Types")
rstTypes.AddNew
rstTypes!ContactType = NewData
rstTypes.Update
Response = acDataErrAdded
Else
Response = asDataErrDisplay
End If
End Sub
This code above references the Confirm function which is:
Public Function Confirm(strMessage As String) As Boolean
Dim bytChoice As Byte
bytChoice = MsgBox(strMessage, vbQuestion + vbOKCancel, "ACE")
If bytChoice = vbOK Then
Confirm = True
Else
Confirm = False
End If
End Function
My combo box feeds off the table tblBuildersLookup. My form name is frmCustInfMain and the combobox is Builders.
I'm horrible with VB so I might just have the form and table references wrong. Thanks in advance for any help!
Scott