• Function With acDialog (A2k)

    Author
    Topic
    #396280

    The following function opens an entry form.
    The acDialog option dis-allows the:

    Forms!frmCalEvent!StartDate = tmp
    Forms!frmCalEvent!EndDate = tmp

    Lines of code to populate because the code is waiting for a response.
    The reason this option resides in the code is because the Form_Current will not operate without it.
    Is there a way to pass these “tmp” values into the form before acDialog prompts.

    Function dateDblclick(id)
        Dim Response As String
        Dim tmp As Date
        'On Error GoTo ErrTrap
        tmp = strMonth & ". " & Me("label" & id).Caption & "/" & intYear
        If Me("id" & id).Caption = "" Then
            Response = MsgBox("Event does not exist for this date." & vbCrLf & _
            "Create a new Event ?", vbYesNo, "Create Entry")
            If Response = vbYes Then
                DoCmd.OpenForm "frmCalEvent", , , "[ID] = " & 0, , acDialog
                Form_Current
                Forms!frmCalEvent!StartDate = tmp
                Forms!frmCalEvent!EndDate = tmp
                                 
            Else
            End If
        Else
            DoCmd.OpenForm "frmCalEvent", , , "[ID] = " & Me("id" & id).Caption, , acDialog
            Form_Current
        End If
        
    'ErrTrap:
        
    End Function
    Viewing 3 reply threads
    Author
    Replies
    • #741459

      You could put the value of tmp in a hidden text box:

      txtHidden = tmp

      Get this value in the On Load event of frmCalevent:

      Private Sub Form_Load()
      Me.StartDate = Forms!frmCalendar!txtHidden
      Me.EndDate = Forms!frmCalendar!txtHidden
      ‘ Other instructions can go here if needed
      End Sub

      Of course, you must remove the offending lines from datDblClick.

      • #741461

        Hans
        I thought that was too easy.
        If there’s an entry, the code is ok.
        If no entry, I can’t assign a value.

        txtTmpDate is on frmCalendar

            If Me("id" & id).Caption = "" Then
                Response = MsgBox("Event does not exist for this date." & vbCrLf & _
                "Create a new Event ?", vbYesNo, "Create Entry")
                If Response = vbYes Then
                    Me.txtTmpDate = tmp
                    DoCmd.OpenForm "frmCalEvent", , , "[ID] = " & 0, , acDialog
                    Form_Current

        And on the event forms open event:

        Private Sub Form_Open(Cancel As Integer)
        If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
        Me.StartDate = Forms!frmCalendar!txtTmpDate ' Can't assign a value error here !!!
        Me.EndDate = Forms!frmCalendar!txtTmpDate
        End If
        End Sub
        • #741463

          Dave,

          Is this the solution, or another question?

          • #741467

            Hans
            It’s the problem ( Can’t assign value )
            Don’t worry too much about it, I’m playing about with the acDialog line.
            In reality, it shouldn’t need this so I may be able to omit it.

            The reason it as included (going back a couple of months now) was the Calendar form didn’t refresh with a new entry and
            it never existed in the original design

            I’ll post if I can’t fix it.

            Have a good weekend

          • #741468

            Hans
            It’s the problem ( Can’t assign value )
            Don’t worry too much about it, I’m playing about with the acDialog line.
            In reality, it shouldn’t need this so I may be able to omit it.

            The reason it as included (going back a couple of months now) was the Calendar form didn’t refresh with a new entry and
            it never existed in the original design

            I’ll post if I can’t fix it.

            Have a good weekend

        • #741464

          Dave,

          Is this the solution, or another question?

      • #741462

        Hans
        I thought that was too easy.
        If there’s an entry, the code is ok.
        If no entry, I can’t assign a value.

        txtTmpDate is on frmCalendar

            If Me("id" & id).Caption = "" Then
                Response = MsgBox("Event does not exist for this date." & vbCrLf & _
                "Create a new Event ?", vbYesNo, "Create Entry")
                If Response = vbYes Then
                    Me.txtTmpDate = tmp
                    DoCmd.OpenForm "frmCalEvent", , , "[ID] = " & 0, , acDialog
                    Form_Current

        And on the event forms open event:

        Private Sub Form_Open(Cancel As Integer)
        If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
        Me.StartDate = Forms!frmCalendar!txtTmpDate ' Can't assign a value error here !!!
        Me.EndDate = Forms!frmCalendar!txtTmpDate
        End If
        End Sub
    • #741460

      You could put the value of tmp in a hidden text box:

      txtHidden = tmp

      Get this value in the On Load event of frmCalevent:

      Private Sub Form_Load()
      Me.StartDate = Forms!frmCalendar!txtHidden
      Me.EndDate = Forms!frmCalendar!txtHidden
      ‘ Other instructions can go here if needed
      End Sub

      Of course, you must remove the offending lines from datDblClick.

    • #741473

      You could also create some global variables (place them in any module) and then fill them before executing the OpenForm method.

    • #741474

      You could also create some global variables (place them in any module) and then fill them before executing the OpenForm method.

    Viewing 3 reply threads
    Reply To: Function With acDialog (A2k)

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

    Your information: