Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39

    Probably gonna need also to make a new command button on one of the forms so the are not both executing the same code???

  2. #17
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    Paul, you are a genious! I pasted it in and it is working great. Should I leave out the Me.Dirty thing?

  3. #18
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    Paul I have one more bug (that I know of) to work out still, maybe you want to play with it since you have a copy.

    The users will only have access through the switch board. When you are in frmSwitchboard and click on the "Add New Project" button I need it to be a requirement that a comment also be made. The reason being that when my query runs to generate the report it will not pick up any projects that do not have a comment since projects and comments are linked.

    Either that or the query somehow needs to pick up projects with no comments (I have not been able to do that)

    I was thinking that when a new project is created, that if they try to close the form a pop up message would tell the user that a comment is required or it will not save. I am a little over my head with this one.

    Thanks, Joe

  4. #19
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    In the BeforeUpdate event of the Form use something like this:

    Code:
        Dim Msg As Variant
        'If there are changes to the record and the Comment field is null...
        If Me.Dirty And IsNull(Me.txtComment.Value) Then
            'Ask the user if they want to go back to add a comment...
            Msg = MsgBox("The record will not be saved without a comment." & vbCrLf & "Would you like to go back and add a comment?", vbYesNo)
            'If they want to go back, cancel the event (closing the form, moving to a new record, etc...) and set the focus to the Comment field
            If Msg = vbYes Then
                DoCmd.CancelEvent
                Me.txtComment.SetFocus
            'Otherwise undo the changes and allow the event to process
            Else
                DoCmd.RunCommand acCmdUndo
            End If
        End If

  5. #20
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    Hey slave138 I am pretty much a novice so I need some clarification, do I use this code as is or do I need to add a form name in this where it says "Me.txtComment.Value" or where it says "Me.txtComment.SetFocus" ??

  6. #21
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Change txtComment to be whatever name you have for your comment field and make sure you replace all instances of it.

  7. #22
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    I just noticed that in the BeforeUpdate event of this form I already have:

    'Tracks when a change on the form was made and by who
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    [Changed By] = Environ("username")
    [Data Changed] = Now()
    End Sub

    How do I incorporate all this together or can I and also the name of the comment field is "Comment"

  8. #23
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You shouldn't need a comment. Edit the join between the two tables and change it to include all records from the projects table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #24
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Quote Originally Posted by jmk909er View Post
    I just noticed that in the BeforeUpdate event of this form I already have:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        Dim Msg As Variant
    'If there are changes to the record and the Comment field is null...
        If Me.Dirty And IsNull(Me.txtComment.Value) Then
    'Ask the user if they want to go back to add a comment... 
            Msg = MsgBox("The record will not be saved without a comment." & vbCrLf & "Would you like to go back and add a comment?", vbYesNo)
    'If they want to go back, cancel the event (closing the form, moving to a new record, etc...) and set the focus to the Comment field
            If Msg = vbYes Then
                DoCmd.CancelEvent
                Me.txtComment.SetFocus
    'Otherwise undo the changes and allow the event to process
            Else
                DoCmd.RunCommand acCmdUndo
            End If
        Else
    'Tracks when a change on the form was made and by who
    [Changed By] = Environ("username")
    [Data Changed] = Now()
        End If
    End Sub
    How do I incorporate all this together or can I and also the name of the comment field is "Comment"
    This is just one of the ways you can do it.
    Last edited by slave138; 10-23-2010 at 06:05 PM. Reason: Reformatting code

  10. #25
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39

    Change relationship

    Hey Paul that sounds good but I can't get it to work I am clicking on "database tools", "Relationships", "Edit Relationships" Please take a look at the attached screen shot and see if I am in the right place or not and what I need to do

  11. #26
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    doc not uploading I will try again

  12. #27
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39

    Doc

    Would not save word doc so I zipped it

  13. #28
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    Paul, I think I did it right but my query still wont pick it up because my query consists of a table combined with a query that only returns the most recent comment instead of all comments so that my report will only have the latest comment and I think that is why it will not return a record that does not have a comment. Am I right?

  14. #29
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Like this, but change INNER to LEFT:

    http://www.baldyweb.com/LastValue.htm

    Relationships is not where I mean; you'd edit the join in query design view by right clicking on the join line. That has the same effect as changing INNER to LEFT as I described above.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #30
    jmk909er is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2010
    Location
    San Diego, CA
    Posts
    39
    YES! Thank you Paul and also slave138 I never know about that trick of right clicking on the connector in query mode. Everything is working GREAT I will have to run it through all it paces to be sure but I thing all the bugs are out. I will be the hero at work thanks to you. Awesome, thanks, Joe

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Link Master Field and Link Child Field
    By evander in forum Forms
    Replies: 2
    Last Post: 05-25-2010, 09:13 PM
  2. Link Master Field Error
    By Lynn in forum Access
    Replies: 6
    Last Post: 04-11-2010, 01:00 PM
  3. Replies: 7
    Last Post: 02-08-2010, 12:14 PM
  4. Link ComboBox to field in a table
    By DrDebate in forum Forms
    Replies: 0
    Last Post: 04-27-2007, 08:03 AM
  5. Create the link
    By accessman2 in forum Access
    Replies: 0
    Last Post: 03-13-2006, 01:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums