Link to home
Start Free TrialLog in
Avatar of military donut
military donutFlag for United States of America

asked on

Search Form Saving Data into Form

Hello,

I have a form that contains a

Main Form and SubForm

I have a Search Form open up to search for some misc Data and then that Search form Hides the Form above with main and sub,  They search and then the button I have does the below opertion.

What is happening is the record is being saved on the subform.  I don't want the record saved after the controls are filled in when it returns to the Form.  More fields need to be filled in first before finishing the record.

The fields being filled in are on the subform so, I don't know what I am doing wrong.

Maybe I need to set the focus on the subform before going to the search form?


Private Sub Command37_Click()
    Forms!frmLicenseSearch2!frmLicenseSearchSub2.Form!Company = Me.Company
    Forms!frmLicenseSearch2!frmLicenseSearchSub2.Form!Make = Me.Make
    Forms!frmLicenseSearch2!frmLicenseSearchSub2.Form!TractorState = Me.TractorState
    Forms!frmLicenseSearch2!frmLicenseSearchSub2.Form!TractorPlate = Me.TractorPlate
    DoCmd.Close
    Forms!frmLicenseSearch2.Visible = True
       
End Sub

Private Sub Form_Load()
If CurrentProject.AllForms("frmLicenseSearch2").IsLoaded Then
    Forms!frmLicenseSearch2.Visible = False
    Me.txtSearch.SetFocus
    Me.txtSearch = Forms!frmLicenseSearch2.LicenseNumber
    DoCmd.ApplyFilter "", "[LicenseNumber] Like ""*"" & [Forms]![Query3]![txtSearch] & ""*""", ""

End If
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of military donut

ASKER

I see what you are saying...what I needed to do was to set the button on the subform.  That way the focus goes to the subform and doesn't save the data after putting the data in.
That sounds right.

/gustav