Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32

    Question Unanswered: Putting a value in a text box

    I'm trying to put some default values into a couple of text boxes when I open a form. The text boxes are unbound as they dont refre to anything in the databse. The form is set to be modal and stay on top - essentially its a dialog.

    This is the code I have to set the text box values and show the form;

    Public Sub PrepareExport()

    Me.txtHTMLTitle.Value = ExportGrid.g_Title
    Me.txtHTMLSubTitle.Value = ExportGrid.g_SubTitle

    DoCmd.OpenForm Me.Name
    Me.txtFile.SetFocus

    End Sub

    Problem is the form is displayed but the text boxes appear blank. How do I show the values I want in the text boxes?


    Also, when the user clicks the OK button, I want to perform a load of processing then close the form, so I have;

    Private Sub cmdOK_Click()

    'Loads of processing here.....

    DoCmd.Close acForm, Me.Name

    End Sub

    The processing bit happens but the form doesnt close. What is the correct way to close the form?

    Thanks.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    What is ExportGrid? Is it a user defined Object?

  3. #3
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32
    ExportGrid is a module, and g_.... are public variables (strings) in that module

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    DoCmd.Close acForm, Me.Name is correct.

    Do you get a message error concerning closing the Form?

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by village idiot
    ExportGrid is a module, and g_.... are public variables (strings) in that module
    Try the folloing in the on Open event of your form

    Me.txtHTMLTitle = g_Title

  6. #6
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32
    Dont get any errors when trying to close the form with this command, it just doesnt close. If I put a breakpoint on this line I can see it is executed though - it just does nothing!?

  7. #7
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32

    It worked

    Thanks muchly,

    Using the on open event worked.

    Any more ideas about closing the form?

  8. #8
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by village idiot
    Dont get any errors when trying to close the form with this command, it just doesnt close. If I put a breakpoint on this line I can see it is executed though - it just does nothing!?
    In the Break point position, put the cursor on Me.Name and check for the Form's name. also try DoCmd.Close acForm, "yourFormsName"

  9. #9
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32
    I tried
    DoCmd.Close acForm, "frmExportGrid"
    it was executed but did nothing.

    I also tried
    DoCmd.Close acForm, Me.Name
    it was executed but did nothing.

    I've tried stepping through and the line does nothing. I also did it without stepping through and the same nothingness happens.

  10. #10
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    If you want, you can send this form to check it, I use ACCE$$ 97

  11. #11
    Join Date
    Apr 2004
    Location
    Kampala, Uganda
    Posts
    32
    Im using Access 2002, SP2

    Thanks for your help.

    Are you Egyptian or German?

  12. #12
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Egyptian live in Germany

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •