Hi all,
I have created user input form and to help with ease of input, I have decided to pull records in to a list box, user selects an item and the item updates to the bound text box field. The textbox populates but produces an error and I cannot continue unless I clear the text box.
run time error '2115'. The macro or function set to the BeforeUpdate or Validation rule for this field is preventing MS Access from Saving the data in the field.
Oddly, I can type the data in the bound field and tab on through the form until I save the record.
My setup
Form bound to tblMain
txtACode.text bound to tblMain!ACode
txtISIN.text bound to tblMain!ISIN
To help with selection of the appropriate records
My query pulls in ACode & AName data from TblA with criteria
Like [Forms]![frmDistributionAddEdit]![txtAgentCode] & "*"
This helps with searching and the listbox is populated accordingly.
On the form in the List box After Update event, I have tried setting the text box directly, an unbound text box and now a variable and all 3 fail with the error. The text box is populated
Should I be using the AfterUpdate event of the listbox? Are there any other suggestions to allow a user to select data if they start typing part of the required field entry?
I have created user input form and to help with ease of input, I have decided to pull records in to a list box, user selects an item and the item updates to the bound text box field. The textbox populates but produces an error and I cannot continue unless I clear the text box.
run time error '2115'. The macro or function set to the BeforeUpdate or Validation rule for this field is preventing MS Access from Saving the data in the field.
Oddly, I can type the data in the bound field and tab on through the form until I save the record.
My setup
Form bound to tblMain
txtACode.text bound to tblMain!ACode
txtISIN.text bound to tblMain!ISIN
To help with selection of the appropriate records
Code:
Private Sub cmdAgentSearch_Click()
bAgentSearch = True
lstSearch.RowSource = "qryDistributionASearch"
End Sub
Like [Forms]![frmDistributionAddEdit]![txtAgentCode] & "*"
This helps with searching and the listbox is populated accordingly.
On the form in the List box After Update event, I have tried setting the text box directly, an unbound text box and now a variable and all 3 fail with the error. The text box is populated
Code:
Private Sub lstSearch_AfterUpdate()
Dim sPopulate As String
If bAgentSearch = True Then
sPopulate = lstSearch.Column(0)
MsgBox sPopulate
txtACode.SetFocus
txtACode.Text = sPopulate
Else
sPopulate = lstSearch.Column(0)
txtISIN.SetFocus
txtISIN.Text = sPopulate
End If
bAgentSearch = False
End Sub