Solved

Search Form Saving Data into Form

Posted on 2015-02-04
4
169 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

914 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

19 Experts available now in Live!

Get 1:1 Help Now