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!

Access Custom Dialog from VBA

Status
Not open for further replies.

CSams

Technical User
Jan 26, 2003
5
0
0
DK
Hi,

I'm trying to create a custom dialog form from an already existing form. I thought something like this would work:

Dim InputClass As Form
Set InputClass = New Form_ClassSelect

InputClass.Visible = True

The form shows up nicely, but my code continues running without waiting for the form to hide/close despite the fact that I've set the Borderstyle to dialog, PopUP True, and Modal True.
Any help is much appreciated :)

Best Regards,

CSams
 
Are you getting a return value from the form or waiting for some event to occur on the form? Otherwise, it seems your code has no reason to stop and wait.
 
Hi!

Is there any reason you can't use the docmd.openform thingie?

[tt]docmd.openform ClassSelect,,,,,acdialog[/tt]

This halts code execution until the form is closed and the focus is back on your original form.

Roy-Vidar
 
Dear MisterC and Roy-Vidar,

Thank your for your kind interest, I should have pointed out 1) yes, I do need a return value based on an option group containing radio buttons, and 2) I don't know how to handle return values using the docmd.openform ClassSelect,,,,,acdialog thingie except from creating a new module holding the return value.
So I'm trying to get away from always having to create extra modules when making a custom input form.

Best Regards,
CSams
 
Hi!

Been offline for a while, sorry. Have you been able to solve this?

No pun intended when using the term "docmd.openform thingie", it was just a bit difficult to judge wether stating "opening the form in dialog mode" would suffice.

Creating an instance of a form thru code isn't within my experience, think I saw a thread about it some weeks ago, don't know if they were able to solve return value/using values from the form.

So to continue a bit with "ordinary" opening of forms, there are two elements.
1 - halting code excecution when/after opening another form
2 - returning a value from the opened form (when closing or whatever)

Adressing the latter:

If you're using several of these in the same application (several forms where the need of using global variables is present), it'd suffice declaring all the globals in one module. Some members like to create a module where only global variables and functions reside/are declared.

Stead of using globals, you could just push/write the value to the calling form thru ordinary forms references.

You'll also see some members recommending having a hidden form open as long as the db is open (perhaps the main menu). Controls on this form might then be used as global variables. This might seem like a possibility for your custom form/dialog box.

Halting code execution:

I've seen several ways of halting code execution, waiting for return values, for when opening other applications outside Access/Office. But I'm not avare of other methods than opening the form in dialog mode when opening a form within Access. Perhaps other members have other knowledge/experience...

HTH Roy-Vidar
 
Roy-Vidar:


Thanx for your input - I think I'll go ahead with OpenForm/Global Variable solution.

b.r.
CSams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top