Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    Unanswered: One line of code

    Hi all,

    I have attached a mini database - here is my dilemna (I have tried various combinations of code but just can't get it right)

    Here is the scenario:
    Open the frmHMO
    I would like to double click on a date received and have the comments box pop up.
    Then, after filling in comments, close the comments box.
    Then go back and double click the same date and have the comments previously entered pop up.

    PLEASE HELP ! !

    Thank you,

    Michael Abrams
    Last edited by mrabrams; 06-18-02 at 14:07.

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    I did download this, but I cannot repost it, as I am running XP and have had to open it in XP to make it work. So I will try and post the changes I made.

    1: frmReceivedSubform - Add REC_ID (to the header) and set property to visible = no

    2: I played with the form names and took out the spaces

    3: I played with the code

    Private Sub DATE_RCVD_DblClick(Cancel As Integer)

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmnotes"


    DoCmd.OpenForm stDocName

    '[Forms]![frmHMO]![frmReceived SubForm]![Forms]![frmnotes].[REC_ID] = [Forms]![frmHMO]![frmReceived SubForm]![Forms].[REC_ID]

    '[Forms]![frmHMO]![frmReceived SubForm]![Forms]![frmnotes].Open
    End Sub

    4: I deleted the code behind form notes

    5: Icreated a query and copied the SQL as below to the form notes recordsource

    SELECT tblNotes.NOTES_ID, tblNotes.REC_ID, tblNotes.COMMENTS
    FROM tblNotes
    WHERE (((tblNotes.REC_ID)=[Forms]![frmHMO]![frmReceivedSubform].[Form]![REC_ID]));

    6: Finally I tested the changes by making notes 2,3,4,5,6,7,8 and giving them the same REC_ID in the table tblNotes.

    All tested okay. I have not tried adding a new record but it should work fine.
    Last edited by dynamictiger; 06-06-02 at 21:46.

  3. #3
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    I can't wait to try it out !!

    Thank you sooo much - I will post back tomorrow with the results.

    Again - I appreciate the time you invested in this. Many thanks.

    Michael

  4. #4
    Join Date
    Feb 2002
    Posts
    403
    I found an error when I went to add a new record. This code fixes it.

    Private Sub Form_Load()


    If Me.REC_ID = 0 Then

    Me.REC_ID = Form_frmReceivedSubform.REC_ID

    End If


    End Sub

    It goes into the frmNotes.

  5. #5
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    I'm getting close !!

    dynamictiger:

    I have placed the code as you recommended.
    When I double click, a parameter box pops up.

    My guess is that I have a parenthesis or bracket that shouldn't
    be there. Could you, if you have time, take a look to see the
    error of my way?

    Thank you very much for your time and patience.

    Michael Abrams.


    edited for spelling !!!
    Attached Files Attached Files
    Last edited by mrabrams; 06-18-02 at 10:32.

  6. #6
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    Lightbulb Help?

    Has anyone who has downloaded this been able to see what is wrong?
    (And maybe how to fix it?)

    THANKS!!

    Michael

  7. #7
    Join Date
    Feb 2002
    Posts
    403
    The attachment is converted from 2002 to 97. You will have to compile all modules and fix any missing references.
    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    THANKS!!!!!!!!!!!!!

    dynamictiger: THANK YOU VERY MUCH!!
    It absolutely works as advertised.

    I appreciate your time and knowledge.

    Michael Abrams

  9. #9
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    One more

    There will come a time where the user double clicks, the Notes box will pop up, and they change their mind and not type any comments.
    A record is created though in the notes table.
    How do I code and where does it go (On Form Close?) for this?

    Pseudocode:

    On Form_Close()
    If Isnull(Me. Comments) then
    ** Do not create a new record in Notes**
    End if

    Thanks again !!
    Michael

  10. #10
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    help?

    Can anyone tell me how to prevent creating a new record as outlined above?

    Thanks again!!
    Michael

  11. #11
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    Please !!??

    Anyone have an idea for this?

    Thank you,

    Michael Abrams

  12. #12
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    Hey Michael,

    You could try this code and it should work:

    On Form_Close()
    On Error Resume Next
    If IsNull(Me.Comments) Then
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdUndo
    DoCmd.SetWarnings True
    End If
    End Sub

    This will undo whatever changes the user makes for the current record. You should note however that the wheel on a mouse will allow users to scroll through records because you have the Allow Additions, Allow Deletions, etc.. fields set to yes. I'm not sure if this is what you meant to do or allow. You could change those settings to No and then change your Open Form command to acFormAdd. Then that will only allow the addition of comments without scrolling through other recordsets, and also will allow the above Undo command to work properly. You also could take out the close button on your form and place two additional buttons on your form named Save and Cancel. Then place the appropriate code for each button to either save and close or undo/cancel and close.

    Does this help you??????
    Kal

  13. #13
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    Does this help you??????
    The short answer: YES !!!!!!!!!!!!!

    Thank you so much. It is just what I needed to complete the puzzle.

    Thanks KAL !!

    Michael

Posting Permissions

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