Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Search Form Saving Data into Form

Posted on 2015-02-04
4
Medium Priority
?
182 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 1000 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 1000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 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