Solved

Search Form Saving Data into Form

Posted on 2015-02-04
4
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 51

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 51

Expert Comment

by:Gustav Brock
ID: 40591278
That sounds right.

/gustav
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

617 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