?
Solved

How to Move to a record on a form based on another forms data

Posted on 2015-02-04
9
Medium Priority
?
129 Views
Last Modified: 2015-02-05
I have a main form... On the main form I have a button that brings up a small form named Reservations.  On this Reservations form there is a combo box that searches for a reservation number.  The search is working fine.  The reservation form is a modal... I would like to put a button on the reservation for that says "Go to this record"... when you click the button, the modal- Reservations form closes and the form that is open in the background moves to the id that was in the Reservations form...

I think I know how to do this when the forms are closed but I don't know the coding for the form that is already open.
0
Comment
Question by:Shaft960
[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
  • 5
  • 4
9 Comments
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 40590456
On the search form, use this code in OnClick event of the goto button:

    DoCmd.OpenForm "YourBackgroundFormName", , , "ID = " & Me!txtReservation.Value & ""
    DoCmd.Close acForm, Me.Name

Adjust ID to the name of the Reservation field on the background form.
Adjust txtReservation to the name of your textbox on the search form.

If reservation number is Text, apply single quotes:

    DoCmd.OpenForm "YourBackgroundFormName", , , "ID = '" & Me!txtReservation.Value & "'"
    DoCmd.Close acForm, Me.Name

/gustav
0
 

Author Closing Comment

by:Shaft960
ID: 40590461
Thanks... I know that was kinda simple but I was blowing it.... Nice job
0
 

Author Comment

by:Shaft960
ID: 40590477
Is there a way that it will go to the forms and show all of the records but just be on the record that I wanted... It is going there but it shows filtered records...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40590500
Yes. You can either just push the Filtered button at the bottom of the form.
Or run this code from the button:

    DoCmd.SelectObject acForm, "YourBackgroundFormName"
    DoCmd.SearchForRecord  , , , "ID = " & Me!txtReservation.Value & ""
    DoCmd.Close acForm, Me.Name

/gustav
0
 

Author Comment

by:Shaft960
ID: 40590540
I am getting error messages now.. Method or data member not found
0
 

Author Comment

by:Shaft960
ID: 40590542
DoCmd.SearchForRecord , , , "ID = " & Me![ID]
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40590547
Oh, it use the wrong "Me":

     Dim SearchID As Long
     SearchID = Me!ID.Value
     DoCmd.SelectObject acForm, "YourBackgroundFormName"
     DoCmd.SearchForRecord  , , , "ID = " & SearchID & ""
     DoCmd.Close acForm, Me.Name

 /gustav
0
 

Author Comment

by:Shaft960
ID: 40590550
Error pops up and it highlights the SearchForRecord text...
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40590602
Then something else is going on.
The sample works (right-click, Save As ..., change extension to accdb, Ok).

/gustav
DbSearch.accdb
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

649 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