Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Préverenges, Switzerland

    Question Unanswered: set .value in control strThisControl ???

    i have a popup utility form which will "called" by many other forms in my application. the popup receives the name of a control in the caller as one of the OpenArgs, and is supposed to return a value to that control.

    the popup successfully parses OpenArgs and sets it's local variable strReturnValueTo according to the appropriate part of OpenArgs ( e.g. strReturnValueTo = "Forms!CallerForm.ControlName" )

    now my mind is blank: how can the popup post it's return value to the control defined in the string strReturnValueTo

    i'm looking for something like
    strReturnValueTo.Value = localBox.value 'this does not work

    thanks for your thoughts.


  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland

    workaround so far

    couldn't find a way to use a string holding "Forms!name!control" to set the .value in that control.

    here's my work-around for the moment.

    popUserDate is a popup/modal utility form with a calandar control and a lots of buttons for speed-setting special dates (today, end-of-month, +10, +20, +30, +60, +90 days, +1, +2, +3 months, year-end, year-start etc etc etc).

    18 textboxes on 12 forms need this user date input: too messy to use embedded calander controls.

    i don't really like this workaround's call to ..Setup after opening the form. anyone got a more elegant way to send a target object to a form on open? i do not want to use any global vars for this.


    Option Compare Database
    Option Explicit
    '   FORM popUserDate
    '   utility form to gather a user-entered date and insert it in the calling form
    '   calling form must use the following syntax:
    '       Dim TargetTextBox As TextBox                                                	'prepare textbox object
    '       Set TargetTextBox = Me.NameOfTheTargetTextBox                               	'set the target textbox
    '       DoCmd.OpenForm "popUserDate"                                                	'open the form
    '       Forms!popUserDate.popUserDateSetup TargetAsTextBox, "Caption", DefaultAsDate  	'call the setup routine
    '       on error TargetAsTextBox is unchanged else TargetAsTextBox = user selected date 
    Dim PUDtarget As TextBox    	'will be set to the TargetTextBox in the calling form by popUserDateSetup
    Public Sub popUserDateSetup(theTarget As TextBox, theCaption As String, theDefault As Date)
        Set PUDtarget = theTarget   'keep a local copy of the target textbox object
        Me.Caption = theCaption     'set the form caption
        theCal.Value = theDefault   'set the initial value
    End Sub
    Private Sub butOK_Click()
        '.....some error checking
        PUDtarget.Value = theCal.Value
        DoCmd.Close acForm, "popUserDate"
    End Sub

Posting Permissions

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