Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i opened a form using DoCmd.OpenForm "Name",,,,,acDialog 1

Status
Not open for further replies.

ruthcali

Programmer
Apr 27, 2000
470
0
0
US
i am using Access97.

My form opens as a Dialog, but the scroll bars are not there.

i have Scroll Bars set to 'both' on the form. does opening a form as a Dialog take away the scroll bars?

thanks,
ruth ruth.jonkman@wcom.com
 
Looks like you are out of luck unless you do it another way. I just created a form without a record source and then placed a sub form on this form for the records I wanted to see. The main form can be opened in dialog mode however the subform will have the scroll bars you are looking for.

John A. Gilman
gms@uslink.net
 
By definition a dialog box does not have scroll bars.

Just curious (Im sure you have good reason), but why not open in another mode ?

Could you accomplish your goal using the using the popup or modal properties ?


Dave
gallagherd@earthlink.net
 
DaveSH, the neat thing about Dialog mode is that your code is suspended until the form closes. This will allow the user to make a selection or some other decision that will allow the code to continue conditionally. Neat stuff when you need user interaction as code is executing.
John A. Gilman
gms@uslink.net
 
Ah ... I got ya.

Thanks
Dave
gallagherd@earthlink.net
 
thanks for your responses!

My main thing is focus.

I have a form called frmName where the user enters his name/password.
That takes him to a form called frmSwitchboard. (where he can navigate through the database)

Between the two forms, my boss wanted me to make a pop up annoying form to remind the users of any late, or soon to be late projects. So I created a form called frmLateProjects.

So now on the FormLoad event of frmSwitchboard, I have DoCmd.OpenForm “frmLateProjects”,,,,acDialog.

On the OnOpen event of frmLateProjects I have the following code to close the form if there is no data:

On Error Resume Next
'if there are no late projects, display a message and close the form
If Me.ID_No.Value = "" Then
MsgBox "You have no late projects!", , "No Late Projects"
DoCmd.Close
End If
If Err.number = 2427 Then
DoCmd.Close acForm, "frmLateProjects"
End If

If I don’t open the frmLateProjects as Dialog, then frmName is the focus after the user closes frmLateProjects, not frmSwitchboard.

FrmLateProjects opened not as Dialog:
The user enters his name and password, then he sees frmLateProjects appear with its scroll bars. (good).
He closes frmLateProjects and sees frmName again (not good, I want him to see frmSwitchboard). frmSwitchboard is opened, it’s just not the focus.

FrmLateProjects opened as Dialog:
The user enters his name and password, then he sees frmLateProjects appear with no scroll bars. (not good).
He closes frmLateProjects and sees frmSwitchboard (good).

I need frmName to stay open, but I don’t want it to get the focus after the user closes frmLateProjects.


Overall, is there a more efficient way to do this pop up form thing? It seems a bit slow in general.

Thanks,
Ruth ruth.jonkman@wcom.com
 
On the close event of your FrmLateProjects do this.
Forms("frmSwitchboard").SetFocus John A. Gilman
gms@uslink.net
 
John,
thanks for writing.

that's a good suggestion, but it won't work because other forms also open the frmLateProjects.

i have a few frmSwitchboard forms:
one called frmSwitchboardEmployees, one called frmSwitchboardManagers, one called frmSwitchboardProjectManagers, etc.

so if i put the code in the OnClose event, i am sure to get an error eventually "...Access cannot find the form..."

ruth.jonkman@wcom.com
 
use the openArgs part of the DoCmd.OpenForm "FrmLateProjects",,,,,,"Form To Return To"
that way you can tell the form what to do when it is closed.
in your onclose event check the information you placed into the OpenArgs and take the required action. I use it this way sometimes. I put the name of the form I want to set the focus to in the OpenArgs property. Then on the close event it looks like this
Dim ReturnTo as String
ReturnTo = Me.OpenArgs
Forms(ReturnTo).SetFocus
John A. Gilman
gms@uslink.net
 
Hi john,

hmmm. it's not working. i did everything you said. I put the "frmSwitchboardEmployees" at the end of the docmd.openform command as the open args.

then i copied and pasted your ReturnTo code above for the OnClose event of the frmLateProjects.

but, it still keeps the focus of frmName after closing frmLateProjects.

ruth.jonkman@wcom.com
 
John,

what about this:

on the frmName, i have:

Forms("frmName").Visible = False

do you foresee any problems with that since once the users enters his name and password, he doesn't need the frmName anymore.

ruth ruth.jonkman@wcom.com
 
Ruth,

If you are having to recall the users name and password in another spot in your application, what you could do is set two globals for them in a module:

global gUserName
global gPassword

That way when they login, you can capture this information, without having to keep that form running in the background.

just make sure you clear the globals when you exit the application...

 
Ruth,

If you are having to recall the users name and password in another spot in your application, what you could do is set two globals for them in a module:

global gUserName
global gPassword

That way when they login, you can capture this information, without having to keep that form running in the background.

just make sure you clear the globals when you exit the application...

You can do this by saying anywhere in your code:

gUserName = ""

 
ruthcali, have you used the break mode for watching code execution?
This will allow you to see just what is happening as your code executes. John A. Gilman
gms@uslink.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top