?
Solved

Reference Data from Dialog Box to Main Form

Posted on 2006-05-21
5
Medium Priority
?
251 Views
Last Modified: 2008-03-17
I have a form (frm_MainLog). When selecting one of the records to close from that form, I have a dialog box (popup, modal) that is opened and requires information to be entered in a specific format. The dialog box (frm_Input) is unbound and has one textbox field (CaseNumber). I do not want to use the inputbox method (which I have been using), as it does not permit me to use an input mask to insure that the data is entered in the specific and correct format.
I now need to move the input data from the dialog box textbox to a string variable in the code of the form (frm_MainLog). The variable is [sresponse] (where it is later concatenated with another variable, before being posted to the appropriate field in frm_MainLog)

The problem I am having is
 (1) how to reference the dialog's textbox and post the data to the main forms declared variable, then
(2) close the dialog without having to add any command buttons to the dialog. (do I close the dialog box in frm_MainLog code, or use an AfterUpdate event in the dialog box code?)
Would appreciate the help.
Bob
0
Comment
Question by:Bob_Gardner
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 16729293
u can do one of two things

define a global variable in a module

then use that in both your forms

or define a public procedure in your form, then call that passing in your inputted text
this public procedure will then set the variable


this all done on the OK button, after that, u close the form DoCmd.Close


Just a thought, feedback purposes only, I wondered why u gave a C when I suggested using a unbounded box and which is what your doing now
0
 
LVL 58

Accepted Solution

by:
harfang earned 2000 total points
ID: 16729309
Hello Bob_Gardner

The standard way to do this (mimic an input box) is to have two buttons [OK] (property Default: yes) and [Cancel] (property Cancel: yes), with these event handlers:

Private Sub cmdCancel_Click()
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdOK_Click()
    Me.Visible = False
End Sub

The main form then uses this:

    DoCmd.OpenForm "frm_Input", WindowMode:=acDialog
    ' (code is interrupted while that form is open and visible)
    If SysCmd(acSysCmdGetObjectState, acForm, "frm_Input") Then
        ' form is only hidden, we can use it...
        Me.txtSomething = Forms!frm_Input!CaseNumber
        ' and close now!
        DoCmd.Close acForm, "frm_Input"
    Else
        ' the user pressed [Cancel], [Esc] or [x] to close the form
        ' do something else here?
    End Sub

Try it that way. It's totally intuitive. Just pressing [Enter] after typing the case number activates the [OK] button (because of the property Default: yes) and just [Esc] cancels the operation.

Cheers!

(°v°)
0
 

Author Comment

by:Bob_Gardner
ID: 16736269
The answer I received from harfang was presented in such a manner that I was able to fully understand the dynamics. To say that it worked, is an understatement. I modified his suggestions in several ways, including using comboboxes in the input form to restrict, even further, the type of acceptable information.
As a result, I have INCREASED the points to 500 and graded the answer "A".
I have also, extended my apologies to rockiroads for the "C" grade that I gave, through my own ignorance, of the question that preceed this one. That apolgy is posted as a comment in the orginal question.
0
 
LVL 58

Expert Comment

by:harfang
ID: 16736551
Thank you, Bob_Gardner, for your compliments and also for the ponts. I'm glad you liked the explanations. If you feel that way about rockiroads and your previous question, you could send a little note in http:/Community_Support/ titled "Please reopen", with only this line:

    Please reopen {http:/Q_21851601.html} to let me change the grade.

They often do it within minutes, it's really quite frequent.

Good luck with your application!
(°v°)
0
 

Author Comment

by:Bob_Gardner
ID: 16738975
Harfang,
Thanks for the info. I have do so!
Bob
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question