Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bookmark form before Design then Open to same record

Posted on 2013-12-07
15
Medium Priority
?
480 Views
Last Modified: 2013-12-07
Experts,

I have a form.
I Design the form.
I do stuff.
Then open again.

I need the form to open to the same record [ID] I was on before I Designed the form.  I am sure this has something to do with Bookmark but I dont know what events to use  under this particular type of scenario.  

thank you
0
Comment
Question by:pdvsa
[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
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39703613
you can only do that by filtering the record source of your form using the record ID you are working on.

if you are working on record id 1
use a query like this as record source of your form

select * from tableName where recordID=1

after your design work is done, replace the record source of the form


you can also store the record ID to a table and use it to filter the record source of the form
0
 

Author Comment

by:pdvsa
ID: 39703648
OK how would I make the recordID more dynamic?  I probably dont understand completely but what I mean is the select * is hard coded to recordID = 1 and I can be on 1 of thousands of record ID's.  

I thought using bookmark and that     Dim vID and vID = Me.ID code you gave me yesterday or some kind of combination would be the solution or maybe a tempvar.  I do open the  form using tempvar but delete the tempvar after opening.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39703675
ok.. try this

private sub form_current()

tempvars.add "myID", me.ID.value


end sub

private sub form_load()

if not isnull(tempvars!myID) then

with me.recordsetclone
      .findfirst "[ID]=" & tempvars!myID
      if not .nomatch then
            me.bookmark =.bookmark
      end if
end with

end if

end sub
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 39

Expert Comment

by:PatHartman
ID: 39703700
Bookmarks change each time a query runs.  Only the Unique ID of the record is a permanent identifier.  Since you are going into design view (I'm not even going to ask but I will tell you this is poor practice and will not work if you need to distribute using the runtime engine), the query needs to run again when the form reopens.  That means a new set of bookmarks.  So, save the ID in a Tempvar or in a table if you need it to persist longer.
0
 

Author Comment

by:pdvsa
ID: 39703717
Pat:  using bookmarks is poor practice?  

I have code in On Load right now (as a macro).  I converted to code and am encountering an error.  About to post it in a separate question.
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 39703741
It is not that using bookmarks is poor practice.  They simply won't work from one recordset to another so you will need some other place to save the record ID (not the bookmark).  Bookmarks are regenerated each time a recordset is opened.  

The poor practice is putting an object into design view to make changes to it on the fly.
0
 

Author Comment

by:pdvsa
ID: 39703757
How else could changes be made to an object if not through design mode?
0
 

Author Comment

by:pdvsa
ID: 39703759
Or do you mean go to the object on the left (db window)?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39703761
@pdvsa

did you test the codes i posted?
0
 

Author Comment

by:pdvsa
ID: 39703768
Cap:  actually not yet...only because I currently have on Load event there and as a macro and conerted to code and get the error... I see u posted a response.  I will be at computer after a bit.

Not at computer at moment.  Thank you (sent from phone)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39703771
you know that after the testing period, you have to removed those codes, right?
0
 

Author Comment

by:pdvsa
ID: 39703773
"I see you posted a response". I meant on my other question posted a few min ago.
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 39703779
Why do you need to make design changes when the user is interacting with the app?  Design changes should be made in design view by YOU.  Users should simply be using the app to work with data.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39703862
Backing up Pat's comment here --  Doing runtime design changes through code might be a good academic exercise, but it is a bad idea in a production database for a variety of reasons.  The reason that always jumps to mind is that code like that WILL fail if you ever need to distribute your database in accde/mde format to users in a runtime environment.

That said, I'm not sure that you both are thinking on the same plane.

<<
I have a form.
I Design the form.
I do stuff.
Then open again.
>>

Are you doing these design changes manually, or are you automating them with code?

EDIT:

Just to be clear, I'm not looking for points in this thread -- just trying to clear up what I think might be a misunderstanding (either between you and Pat or completely on my part)
0
 

Author Closing Comment

by:pdvsa
ID: 39703879
Excellent.   That worked.  I deleted the previous codes and am now using yours On Load event.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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 …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

719 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