Solved

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

Posted on 2015-02-04
9
121 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
  • 5
  • 4
9 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
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
Comment Utility
Thanks... I know that was kinda simple but I was blowing it.... Nice job
0
 

Author Comment

by:Shaft960
Comment Utility
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
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

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

Author Comment

by:Shaft960
Comment Utility
DoCmd.SearchForRecord , , , "ID = " & Me![ID]
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
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
Comment Utility
Error pops up and it highlights the SearchForRecord text...
0
 
LVL 49

Expert Comment

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

/gustav
DbSearch.accdb
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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…

744 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

10 Experts available now in Live!

Get 1:1 Help Now