Hi everyone, hope everyone is well and staying safe!
Back for a little Search function syntax assistance.
I have a search form that opens another form with results in a subform that use the original search form's input. Most of the time, it will display all possible results (it includes name, dob, phones, addresses, etc.). Sometimes, however, it will only produce a single result. In this case it is because only one record matches the criteria.
I would like to have it so the record will automatically be shown in the correct form.
The structure is:
[Worker Form]
[Main Search Form] (for user input)
opens
[Search Form Results]
[sub-form with actual results]
When I double-click the Name field of the Search Form results, it will load that record in the [Worker Form]
How would i get the [Search Form Results] to check onload event if the total results are = 1 to then open that result in the [Worker Form] without the need for the user to double-click the field.
The code below is the on double-click event for the Search-Form with the Subform with Results:
Subform:
Any suggestions would be appreciated!
Back for a little Search function syntax assistance.
I have a search form that opens another form with results in a subform that use the original search form's input. Most of the time, it will display all possible results (it includes name, dob, phones, addresses, etc.). Sometimes, however, it will only produce a single result. In this case it is because only one record matches the criteria.
I would like to have it so the record will automatically be shown in the correct form.
The structure is:
[Worker Form]
[Main Search Form] (for user input)
opens
[Search Form Results]
[sub-form with actual results]
When I double-click the Name field of the Search Form results, it will load that record in the [Worker Form]
How would i get the [Search Form Results] to check onload event if the total results are = 1 to then open that result in the [Worker Form] without the need for the user to double-click the field.
The code below is the on double-click event for the Search-Form with the Subform with Results:
Subform:
Code:
DoCmd.Close acForm, "Search-Workers", acSaveNo
DoCmd.Close acForm, "SearchForm-W", acSaveNo
If CurrentUser() = "Blah blah" Or CurrentUser() = "blah" Then
DoCmd.OpenForm "NewEmployeeForm", , , , , , Me.EmployeeID
If CurrentProject.AllForms("NewEmployeeForm").IsLoaded Then
Forms!NewEmployeeForm.Recordset.FindFirst "EmployeeID=" & Me.EmployeeID
End If
Else
DoCmd.OpenForm "Employees", , , , , , Me.EmployeeID
If CurrentProject.AllForms("Employees").IsLoaded Then
Forms!Employees.Recordset.FindFirst "EmployeeID=" & Me.EmployeeID
End If
End If
Any suggestions would be appreciated!
Last edited by a moderator: