Solved

Search Form Saving Data into Form

Posted on 2015-02-04
4
175 Views
Last Modified: 2015-02-05
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
0
Comment
Question by:Ernest Grogg
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 250 total points
ID: 40590435
>  I don't want the record saved after the controls are filled in when it returns to the Form.

But that's how it works by design. Your only option could be, perhaps, to make the controls on the subform unbound so the subform doesn't think it is being edited when these are filled. But that leaves how and when to edit/save the subform.

You may have to rethink your concept.

/gustav
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 250 total points
ID: 40591203
Yes,
I too am confused by what you posted there...

Is the "Data" being saved or the "Filter"

If you do not want the Filter to be saved, do something like this:
    Me.Filter=""
    Me.FilterOn=False
...or perhaps like this, if you want to cancel the filter on another form:
    Forms!SomeForm.Filter=""
    Forms!SomeForm.FilterOn=False

Note that I am really not clear on your design there, ...so I can't say precisely where to try this code, but typically this will go on the close event of the form (if you d not want the form be re-open with the same filter.)

On the other hand, (if we are talking about "data" being saved)  typical Search "controls" are unbound, hence the data typed into them will not be "saved".
So again, based on what you posted, it is not clear what either form is doing, or what.
Or where you are running your code.

If neither suggestion here helps, then you may want to post a small sample database with full instructions.

JeffCoachman
0
 

Author Comment

by:Ernest Grogg
ID: 40591273
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.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40591278
That sounds right.

/gustav
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question