K
koturtle
I need to create a combobox that a user can add a record via a prompt
to save that record to the list. I want the option to use that value
but not add it to the list. I am using Dev's code below to add a new
item to the combobox if the user replies yet. However i want the
option for the user to say no but still use the value once. He
doesn't want it added to the combo list but wants to use it.
Is this possible?
TIA
Private Sub Quantity_NotInList(NewData As String, Response As Integer)
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' This value does not exist in this list
"
strMsg = strMsg & " Do you want to add this value to the list?"
strMsg = strMsg & " Click Yes to add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblquantity", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Quantity = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Rem rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
'*********** Code End **************
to save that record to the list. I want the option to use that value
but not add it to the list. I am using Dev's code below to add a new
item to the combobox if the user replies yet. However i want the
option for the user to say no but still use the value once. He
doesn't want it added to the combo list but wants to use it.
Is this possible?
TIA
Private Sub Quantity_NotInList(NewData As String, Response As Integer)
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' This value does not exist in this list
"
strMsg = strMsg & " Do you want to add this value to the list?"
strMsg = strMsg & " Click Yes to add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblquantity", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Quantity = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
Rem rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
'*********** Code End **************