a run once form

goodhead

Registered User.
Local time
Yesterday, 16:16
Joined
Feb 18, 2013
Messages
37
is it possible to create a form that runs only once when db first run for name etc. And then once saved cannot be changed by end user.

The last bit I can do its just the making it run once as a popup.

Dan
 
is it possible to create a form that runs only once when db first run for name etc. And then once saved cannot be changed by end user.

The last bit I can do its just the making it run once as a popup.

Dan

Hi Dan,
use DCount function to determine if the underlying table/query of the popup form has records. If DCount = 0, then open the form.

Best,
Jiri
 
is it possible to create a form that runs only once when db first run for name etc. And then once saved cannot be changed by end user.

I sort of do this in my apps... I have a "main" form which the autoexec macro starts when the DB opens, once "main" gets done it opens the first form and closes itself. No other form opens form "main" again. Things done in "main" need to be done only once for the entire time the application is open... "boot strap" tasks I refer to it as.
 
It sounds simple.
I tried alsorts. if statements etc

no matter what I do it moans about the expression.

Basically. The main form opens as an exec. I thought it could have a macro set to onload to do an if record count of tblowner = 0 then open form frmrunonce

I tried stuff like this

DCount([Tbl-Owner]![ID]=0



Hi Dan,
use DCount function to determine if the underlying table/query of the popup form has records. If DCount = 0, then open the form.

Best,
Jiri
 
It sounds simple.
I tried alsorts. if statements etc

no matter what I do it moans about the expression.

Basically. The main form opens as an exec. I thought it could have a macro set to onload to do an if record count of tblowner = 0 then open form frmrunonce

I tried stuff like this

DCount([Tbl-Owner]![ID]=0

You can do it with OnLoad but the syntax of the domain function should be

Code:
If DCount("*","Tbl-Owner") = 0 Then 
 
' open the once-only form
 
End If

Best,
Jiri
 
Ok. I now have the form I want to open.
But the run once form opens behind the main form.
Is there a way to force the run once screen to be active?



It sounds simple.
I tried alsorts. if statements etc

no matter what I do it moans about the expression.

Basically. The main form opens as an exec. I thought it could have a macro set to onload to do an if record count of tblowner = 0 then open form frmrunonce

I tried stuff like this

DCount([Tbl-Owner]![ID]=0
 
Ok. I now have the form I want to open.
But the run once form opens behind the main form.
Is there a way to force the run once screen to be active?

Set the property "Pop Up" (on the "Other" tab) of the tblowner to Yes.

Best,
Jiri
 
I have done that.
The main navigation form also has popup and that seesm to take presidence.

I like the main form to float in middle of window rather than fill whole screen, hence why popup is on main form.


Set the property "Pop Up" (on the "Other" tab) of the tblowner to Yes.

Best,
Jiri
 
I have done that.
The main navigation form also has popup and that seesm to take presidence.

I like the main form to float in middle of window rather than fill whole screen, hence why popup is on main form.

Ok, in that case make the run-once form "modal". Set both the property and the open parameter i.e. DoCmd.OpenForm "xxxxx", , , , , acDialog. That should do the trick.

Best,
Jiri
 
another way is to set a "flag" somewhere that indicates the start up process has been run, and test this when opening the setup form.
 
I've added this. still open as I want then the switch round.
They don't seem to like been both popups..

I thought there used to be another way to make a form appear as a poup form or dialogue rather than full screen. Been years since I used last cant remember what it was.



Ok, in that case make the run-once form "modal". Set both the property and the open parameter i.e. DoCmd.OpenForm "xxxxx", , , , , acDialog. That should do the trick.

Best,
Jiri
 
I've added this. still open as I want then the switch round.
They don't seem to like been both popups..

I thought there used to be another way to make a form appear as a poup form or dialogue rather than full screen. Been years since I used last cant remember what it was.

Strange. What version of Access are you using ? I have not had issues with popups (on popups) with A2010. Try closing the run-once form explicitly from the main program, like:

Code:
DoCmd.OpenForm "xxxxx", , , , , acDialog
DoCmd.Close acForm, "xxxxx", acSaveNo

I use this 'second' Close in A2007 and it does have the effect of stopping the execution of the calling program until the called program closes the form from its own module. If you have this code in the OnLoad event, the main module execution should stop before the form display turns on. Good luck.

Best,
Jiri
 
I'm using access 2010.

the runonce form doesn't need to auto close. The save button on the form does that.

The onload code is on the main form which loads when access opens.
I guess i could put a onload code on the runonce form to close the main form. Then have the the save button also open backup the main form once run once form is completed.

IS that what you mean in you reply?


Strange. What version of Access are you using ? I have not had issues with popups (on popups) with A2010. Try closing the run-once form explicitly from the main program, like:

Code:
DoCmd.OpenForm "xxxxx", , , , , acDialog
DoCmd.Close acForm, "xxxxx", acSaveNo

I use this 'second' Close in A2007 and it does have the effect of stopping the execution of the calling program until the called program closes the form from its own module. If you have this code in the OnLoad event, the main module execution should stop before the form display turns on. Good luck.

Best,
Jiri
 
I'm using access 2010.

the runonce form doesn't need to auto close. The save button on the form does that.

The onload code is on the main form which loads when access opens.
I guess i could put a onload code on the runonce form to close the main form. Then have the the save button also open backup the main form once run once form is completed.

IS that what you mean in you reply?

No, I was not saying to close the main form. What I was suggesting was to stop the execution of the main with a second close of the run-once form, i.e. after it closes via button internally. But you should not need to do that in A2010. I have never seen this problem but after checking I have not run a popup main form, so hard to tell.

You can also try this: open the main form as hidden and then set trhe 'Visible' property to true if the test to open the run-once fails or if it fdoes not fail include the Forms!MainForm(or whatever the main form name is).Visible = True in the OnClose event of the Run-once form.

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom