?
Solved

Open pop up form but return focus to same record

Posted on 2005-03-31
12
Medium Priority
?
329 Views
Last Modified: 2012-06-27
I open a pop up form to issue an item from my main form but as soon as I close the popup the cursor goes back to the first record on my main form. I need to be able to stay on the record I was issuing from.
I am using Access 2003 .adp
Any help please.
0
Comment
Question by:livvie
[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
  • 6
  • 5
12 Comments
 
LVL 26

Accepted Solution

by:
dannywareham earned 750 total points
ID: 13672359
Create a public variable:

Public myRecord as String


Capture the value of the record (RecID) before opening the popup form.
When you close teh form, use FindFirst to return to teh previous record:

Recordset.FindFirst "[RecID]= " & myRecord
0
 
LVL 2

Author Comment

by:livvie
ID: 13672494
Danny
Where do I declare the public variable (sorry for such a basic question)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13672531
In a new module.
Save it.

this allows the variable to be used anywhere in your database - so you can pass the value from the main form to your popup and back.

:-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Expert Comment

by:dannywareham
ID: 13672542
BTW. This assumes that you have a unique record identifier (autonumber?) called "RecID"

If it's different, let me know and I'll tailor the code for you...

:-)
0
 
LVL 2

Author Comment

by:livvie
ID: 13672628
I am not using a recordset here just the record source of the form. I was trying to avoid using a recordset.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13672652
That's fine...
Create the variable.
Capture the value and open the popup:

myRecord = Me.Textboxname    'where textbox name is where the record ID is stored
DoCmd.openForm "YourPopUpForm"


Then use something like (to close teh form and fetch the record you were on before):
DoCmd.Close acForm, "MyPopUpForm", acSaveYes
[forms]![mainformname]![ControlName].Setfocus
Recordset.FindFirst "[RecID]= " & myRecord

0
 
LVL 2

Author Comment

by:livvie
ID: 13672911
This line causes a  problem
Recordset.FindFirst "[RecID]= " & myRecord
as the object does not exist I need to be able to refer to the form recourdsource here.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 13672995
Change to this:

Me.Recordset.FindFirst "RecID=" & myRecord

Also, this assumes that "RecID" is the name of the unique field in your table
If it is different, change it...

:-)
0
 
LVL 2

Author Comment

by:livvie
ID: 13673050
This Recordset.FindFirst "[StoresID]= " & myRecord needs to be somewhere on the mainform I am assuming seeing as that is the recordset  I am lookng for the record in. I have put in numerous places like the gotfocus event of the text box that I have setfocus on in the save event of my pop up but I never seem to go into this code. I have also tried the form gotfocus event.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 13673487
Couldn't reproduce the effect.
0
 
LVL 2

Author Comment

by:livvie
ID: 13673833
OK I have a solution to the problem. (don't requery the main form) but I need to requery one field so maybe if anyone has an alternative to requerying the form instead.
0
 
LVL 2

Author Comment

by:livvie
ID: 13673865
I have it. I am requerying the container form of the form I am working on.
dannywareham thanks for you help.
I will give you the points as your solution would work if I wanted to do it that way.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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