Solved: Not In List Event

您所在的位置:网站首页 Rsb1222 Solved: Not In List Event

Solved: Not In List Event

2023-12-13 20:08| 来源: 网络整理| 查看: 265

I am using the following code in a Not In List event for a combo box to allow a user to type in a value not found on the combo box list. The new value is successfully being added to the table in a new record and to the combo list, however, the form is not being updated to reflect the correct values for the other fields in the form (at this point they should all be blank). What code do I add to the following script or to another event to make this happen? 聽(I've tried various methods of Requery. Novice here.)

聽Private Sub cboInstitution_NotInList(NewData As String, Response As Integer)

聽On Error GoTo cboInstitution_NotInList_Err 聽Dim intAnswer As Integer 聽Dim strSQL As String 聽intAnswer = MsgBox("The Lead Institution "聽& Chr(34) &聽NewData &聽_ 聽Chr(34) &聽" is not in the database." &聽vbCrLf &聽_ 聽"Would you like to add it now?" _ 聽, vbQuestion + vbYesNo, "New Lead") 聽If intAnswer = vbYes Then 聽strSQL = "INSERT INTO tblBusinessContacts([ContactInstitution]) "聽& _ 聽"VALUES ('" &聽NewData &聽"');" 聽DoCmd.SetWarnings False 聽DoCmd.RunSQL strSQL 聽DoCmd.SetWarnings True 聽MsgBox "The new Lead has been added to the database." _ 聽, vbInformation, "New Leads" 聽Response = acDataErrAdded

聽Else 聽MsgBox "Please choose an institution from the list." _ 聽, vbInformation, "Leads" 聽Response = acDataErrContinue 聽End If 聽cboInstitution_NotInList_Exit: 聽Exit Sub 聽cboInstitution_NotInList_Err: 聽MsgBox Err.Description, vbCritical, "Error" 聽Resume cboInstitution_NotInList_Exit

End Sub



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3