I have a database developed in MS Access 2000 that allows people to enter training histories for staff. The staff information is stored in tblStaff, and the training histories are stored in tblTraining. The main form (frmDataEntry) contains the staff contact information and a continuous subform displaying the selected staff's training history.
The desire was for the ability to allow the data entry person to search the database by staff's last name. To do this I placed an unbound text box and a command button in frmDataEntry that opens a second form (frmSrchResults ). The second form contains a list box whose row source is a query of tblStaff with the criteria being "Like ([Forms]![frmDataEntry]![txtLNameSrch] & "*")", which displays all the possible matches in the list box on frmSrchResults. The data entry person can either double click on the correct person or highlight the correct person and select a command button that populates frmDataEntry with the selected person.
The original coding I used is as follows:
The above code worked originally when first developed. However, I know receive a runtime error 2162 - A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.
Can anyone help me rewrite this code so that it works? I have searched for code but am unable to find anything.
Thanks!
The desire was for the ability to allow the data entry person to search the database by staff's last name. To do this I placed an unbound text box and a command button in frmDataEntry that opens a second form (frmSrchResults ). The second form contains a list box whose row source is a query of tblStaff with the criteria being "Like ([Forms]![frmDataEntry]![txtLNameSrch] & "*")", which displays all the possible matches in the list box on frmSrchResults. The data entry person can either double click on the correct person or highlight the correct person and select a command button that populates frmDataEntry with the selected person.
The original coding I used is as follows:
Code:
Private Sub cmdMatch_Click() DoCmd.OpenForm "DataEntry frm", acNormal DoCmd.ShowAllRecords DoCmd.FindRecord Forms![frmSrchResults]![txtNameSrchResults].Column(0) DoCmd.Close acForm, "frmSrchResults" [Forms]![frmDataEntry![txtLNameSrch] = "" End Sub
Can anyone help me rewrite this code so that it works? I have searched for code but am unable to find anything.
Thanks!
Comment