Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear all,
I've developed a QV file with information based on the last 5 years and organised by region/market/...
I would like the year to be selected and locked when I reload the data.
Is there a simple way to have this integrated in the script. I tried the following but (of course) it didn't work.
ActiveDocument.Fields("PERIOD_ID").Select "2010";
ActiveDocument.Fields("PERIOD_ID").Lock;
Thanks for your help
Hi,
Try this.
Access Tools > Edit Module copy and past this code.
Sub SelectAndLock
ActiveDocument.Fields("PERIOD_ID").Select "2010"
ActiveDocument.Fields("PERIOD_ID").Lock
End Sub
Click in Check and OK.
After, Access Settings > Document Properties > Triggers > OnPostReload add action External for Run the Macro.
Hi Fernando
Thanks a lot for the quick reply.
It looks OK. And what if I want to have a multiple selection (e.g 2009 AND 2010).
Should I write select (2010, 2009) ? It seems that it is not recognised as a value list.
Rgds
Hi,
You can trys this.
ActiveDocument.Fields("PERIOD_ID").Select "(2010|2009)"
Yes, it is working. Except when there is a partial reload triggered from a macro.
Thanks again for your reactivity
Hi Fernando,
Is there a simple way to execute the macro (Selectandlock) after the partial reload.
On my file the macro (Selectandlock) is working properly after a full reload but not the partial reload.
And the partial reload is deselecting my field even when locked.
Any idea to solve this problem?
Thanks again
I don´t know.
You try put in OnOpen the Run Marcro.
Yes, I put them on OnOpen and OnPostReload but no result....
Remove from OnPostReload, only OnOpen.
Hi Tony,
I don't want to waste your time. But just to inform you that even with OnOpen I have the same result, i.e. selection is lost and I'm not able to select Years anymore, I have to go for a full reload.
Rgds