• Executing a Command in a variable (A2k sp2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Executing a Command in a variable (A2k sp2)

    Author
    Topic
    #359357

    Hi All

    Finally got the following hard coded command to work, now I want this to be dynamic so same calendar code can be used on other date fields.

    Form_frmCriteriaBP.txtEndIssueDate_AfterUpdate

    I have successfully created the command string in variable FormField

    Dim FormField as variant

    FormField = “Form_” & frm.Name & “.” & ctldate.Name & “_AfterUpdate”

    How do I execute the command string in FormField?

    Thanks, John GRaves

    Viewing 0 reply threads
    Author
    Replies
    • #538444

      What exactly are you trying to do? Is “Form_frmCriteriaBP.txtEndIssueDate_AfterUpdate” being called from within frmCriteriaBP or from elsewhere?

      It appears that all you’re doing it trying to call the AfterUpdate event of a particular control. From where and under what circumstances? It would be simpler to have the AfterUpdate events of the the controls call a standard routine with the relevant code in it. Then you could call the same routine from elsewhere without having to reference the control’s afterupdate event at all.

      • #538452

        Hi Charlotte

        After Update Event Won

        • #538463

          You aren’t doing anything wrong. The AfterUpdate event only fires when you actually change data or enter data in the control, not when you change the control’s value from code. But I don’t understand what you mean by this:[indent]


          How can I get the text box After Update Event to activate select date from calendar?


          [/indent] I thought you double-clicked the textbox to pop up the calendar. So what are you actually trying to accomplish? And is this actually a calendar control or one of the others like MonthView or DateTime Picker?

          • #538477

            I have a form with an unbound start date text box that I double click on to popup up a calendar (date picker).

            When I click the calendar a date it copies OK into the start date text box, however the After Update Event text box won

            • #538482

              Try a requery on the textbox.

              You can’t call anything but a public event from outside a form, even if you set a reference to its class module; so you wouldn’t be able to just reuse the calendar form without modifying the forms that would be calling it first. And I’ve never found a way of calling an event procedure the way you’re trying to do it.

            • #538513

              Hi Charollet

              Thanks for your help.

              Finally got the following is code to work.

              Now that it works with hard coded commands, I would like to execute FormField that has the correct command that I dynamically create based on form and control that pops up the calendar.

              How do I eliminate the hard code and execute the correct command that I dynamically connstruct in FormField?

              Thank, John Graves

              =============
              Private Function setdate()
              On Error GoTo error_hand

              Dim FormField As Variant

              ‘ copies selected date back to active field
              ctldate = Screen.ActiveControl

              ‘ the following hardcoded code forces a date field After Upade Event trigger based
              ‘ on form and control that this popup calendar code was double clicked from
              If frm.Name = “frmCriteriaBP” And ctldate.Name = “txtEndReceiveDate” Then
              Form_frmCriteriaBP.txtEndReceiveDate_AfterUpdate ‘ this hard coded command works
              Else
              If frm.Name = “frmCriteriaBP” And ctldate.Name = “txtEndIssueDate” Then
              Form_frmCriteriaBP.txtEndIssueDate_AfterUpdate ‘ this hard coded command works
              Else
              If frm.Name = “frmCriteriaBP” And ctldate.Name = “txtEndExpireDate” Then
              Form_frmCriteriaBP.txtEndExpireDate_AfterUpdate ‘ this hard coded command works
              End If
              End If
              End If

              ‘ FormField contains thet correct dynamically created command that i’m hardcoding above,
              ‘ however I don’t know how to execute the command once constructed in FormField
              FormField = “Form_” & frm.Name & “.” & ctldate.Name & “_AfterUpdate”

              error_hand:
              Resume Next
              DoCmd.Close
              End Function
              ==============

            • #538517

              I don’t know of any way to do this.

    Viewing 0 reply threads
    Reply To: Executing a Command in a variable (A2k sp2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: