Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function With acDialog (A2k)

    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.

    <pre>Function dateDblclick(id)
    Dim Response As String
    Dim tmp As Date
    'On Error GoTo ErrTrap
    tmp = strMonth & ". " & Me("label" & id).Caption & "/" & intYear</pre>


    <pre> If Me("id" & id).Caption = "" Then
    Response = MsgBox("Event does not exist for this date." & vbCrLf & _
    "Create a new Event ?", vbYesNo, "Create Entry")</pre>


    <pre> 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</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function With acDialog (A2k)

    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.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function With acDialog (A2k)

    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

    <pre> 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</pre>


    And on the event forms open event:

    <pre>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</pre>


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function With acDialog (A2k)

    Dave,

    Is this the solution, or another question?

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function With acDialog (A2k)

    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

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Function With acDialog (A2k)

    You could also create some global variables (place them in any module) and then fill them before executing the OpenForm method.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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