Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Executing a Command in a variable (A2k sp2)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Executing a Command in a variable (A2k sp2)

    What exactly are you trying to do? Is "Form_frmCriteriaBP.txtEndIssueDate_AfterUpdat e" 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.
    Charlotte

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Executing a Command in a variable (A2k sp2)

    Hi Charlotte

    After Update Event Won

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Executing a Command in a variable (A2k sp2)

    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:
    <hr>How can I get the text box After Update Event to activate select date from calendar?<hr>
    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?
    Charlotte

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Executing a Command in a variable (A2k sp2)

    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

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Executing a Command in a variable (A2k sp2)

    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.
    Charlotte

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Executing a Command in a variable (A2k sp2)

    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
    ==============

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Executing a Command in a variable (A2k sp2)

    I don't know of any way to do this.
    Charlotte

Posting Permissions

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