Solved

Search Form Saving Data into Form

Posted on 2015-02-04
4
167 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
Comment Utility
>  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
Comment Utility
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
Comment Utility
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
Comment Utility
That sounds right.

/gustav
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now