Full Version: Requery Copied Field
UtterAccess Forums > Microsoft® Access > Access Forms
edin14166
Hello I am taking value from previous record with this cod:
CODE
Me.pocetnoStanjekm.DefaultValue = """" & Me.krajnjeStanjekm.Value & """"

and it works ok.
But I would like keep it in one session because now when I open another form the copied value stays.
I tried with
Me!pocetnoStanjekm.Requery
but without success.
What should I do,
Thanks in advance..
Minty
That would only persist if the form design was saved on exit.
Do you have
CODE
Docmd.Save


At the end of you code somewhere on the form. This will save the form changes not the current record as some people mistakenly think.
edin14166
Hi Minty,

The subform where this action is happening is actually is not closed only filtered, so after few records are entered values
are copied as they should.When user change filter on that subform value is carried from last session where it became false...
Hope You understand...
projecttoday
Did you try
Me.pocetnoStanjekm.DefaultValue = ""
or
Me.pocetnoStanjekm.DefaultValue = Null
in the change-filter code or possible the On Open or On Load event of the form?
edin14166
I just tried with On Open and On Load event of the form but the value stays same....
projecttoday
When you put that code in put a stop on it to make sure it's being executed.
edin14166
hi,
note sure what you mean?
projecttoday
I mean are you debugging your code?

You never mentioned where this default value setting code is located. But in any case the code that clears the default value won't do any good unless it's executed, and executed at the right time. To confirm that, put a stop on it. A stop is a stop-execution request. You can do that by clicking over to the left of the statement in the debug screen.
edin14166
Hi,
The code is debugged...but still it does not work...
missinglinq
The problem is that the OnLoad and OnOpen event's aren't going to fire...because... the Form is already Opened/Loaded! It's just being Filtered! Forms have an OnFilter event...I'd try projecttoday's code there.

Linq ;0)>
edin14166
Hi missinglinq,
Good idea but it does not work...
thank you
projecttoday
Then you have to post it.
edin14166
Hello,
I created sample database with Form Cars and subform Trips. On subform is field ToKm with afterUpdate event:
CODE
Me.FromKM.DefaultValue = """" & Me.ToKm.Value & """"
.It works OK but value is also moved to another car which is not ok...

Thanks in Advance
projecttoday
You want to clear the default value on the main form each time you move to another car. So in the On Current event of the main form:

CODE
Me!frmTrips.Form!FromKM.DefaultValue = ""


edin14166
Thanks, it works now...
I was wrong in referencing form field,,,
Kind Regards'''
projecttoday
You're welcome.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.