Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Bookmark form before Design then Open to same record

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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

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
Avatar of pdvsa

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of pdvsa

ASKER

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.
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.
Avatar of pdvsa

ASKER

How else could changes be made to an object if not through design mode?
Avatar of pdvsa

ASKER

Or do you mean go to the object on the left (db window)?
@pdvsa

did you test the codes i posted?
Avatar of pdvsa

ASKER

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)
you know that after the testing period, you have to removed those codes, right?
Avatar of pdvsa

ASKER

"I see you posted a response". I meant on my other question posted a few min ago.
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.
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)
Avatar of pdvsa

ASKER

Excellent.   That worked.  I deleted the previous codes and am now using yours On Load event.