Results 1 to 3 of 3
  1. #1
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56

    Field to autofill based on value in another form

    Hi,

    I bleieve this is a simple fix, but I can't work out how to write the code.

    I have a review pop up form (frmReview) where a user selects their Name (StaffID), the type of check they are doing (QuailtyType), and the client they want to do it on (clientID). When they press on the 'do review' command button from this form another form opens (frmReviewDetails) which shows the client they selected from the frmReview form as well as a its subform which shows all the sessions that have been entered for this client along with some fields that have not been complted yet regarding review data. I am trying to have it so when they check the 'review check box' in this subform that today date auto populates in the Review date field (this is currently working). I also want it to auto enter the staffID that they selected on the the initial frmReview form.

    This is my currunt code:
    Private Sub Rev_AfterUpdate()
    If Me.Rev = -1 Then
    Me.[RevDate] = Now
    Else: Me.RevDate = Null
    End If


    End Sub

    I hope someone can help me work this out. I really don't want a staff to have to enter their name each and every time they check the review box. Not all box's are going to be checked, so it needs to be on a record to record basis.

    Thanks in advance!

  2. #2
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56
    Sometimes I need to poist to answer my own questions...Murphys law!

    I got it with the code:

    Private Sub Rev_AfterUpdate()
    If Me.Rev = -1 Then
    Me.[RevDate] = Now
    Else: Me.RevDate = Null
    End If

    If Me.Rev = -1 Then
    Me.RevStaff = Forms!frmReview!RevStaff
    Else: Me.RevDate = Null
    End If
    End Sub

    Thanks anyway!

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can condense the code:
    Code:
    Private Sub Rev_AfterUpdate()
    
        If Me.Rev = True Then
            Me.[RevDate] = Now
            Me.RevStaff = Forms!frmReview!RevStaff
        Else
            Me.RevDate = Null
        End If
    
    End Sub
    Be aware that NOW is the date AND time, whereas DATE is just the date....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Autofill field based on combo box
    By topp in forum Access
    Replies: 2
    Last Post: 06-26-2012, 04:36 PM
  2. Replies: 2
    Last Post: 07-14-2011, 09:23 AM
  3. PLEASE help: Autofill based on one field
    By Suzanne in forum Forms
    Replies: 5
    Last Post: 07-07-2011, 11:09 AM
  4. Autofill of a field based on another
    By MyWebdots in forum Forms
    Replies: 7
    Last Post: 07-12-2010, 05:00 AM
  5. Autofill form fields based on another field
    By ljs1277 in forum Access
    Replies: 3
    Last Post: 02-16-2010, 02:51 PM

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