Results 1 to 8 of 8
  1. #1
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66

    Display text field on main form depending on value of text field in sub form

    I am in the process of building a DB for employees training records.

    I have a main form named frmUpdateTraining which has a sub form name subfrmTrainingTimes which is a continuous form.

    On the main from there is a text field named Date_Taken. On the sub form there is a text field named TrainingDate.

    What I would like to do is if the text field TrainingDate is null then the text field Date_Taken is not visible and if the text field TrainingDate contains a date then the text field Date_Taken is visible.



    I have tried using the following code, but it is not working, can anyone help me out please?

    If Is Null[subfrmTrainingTimes]![TrainingDate] then
    Me.Date_Taken.Visible = False
    Else
    Me.Date_Taken.Visible = True
    End If

    Hope that makes sense.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Use the PICKER, to get the path correct....
    prob:

    txtDate.visible= not isnull(forms!fMyform.txtTrainDate)

  3. #3
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Hi ranman,

    How do you mean "Use the Picker"?

    Have tried your suggested code to no avail.

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi Mick

    Logic would have it that you select a Training Name in the Main Form
    Then in the subform you would have the date taken with Times.

    This covers the process of 1 Training name can be attended on Multiple days.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Hi Mike,

    I get what you are saying.

    The subfrmTrainingTimes is a continuous from because there could be more than one training session on different days.

    The Date_taken field is completed when all the training has been completed. My reason for not displaying the Date_Taken field is to force Users to complete at least one record in the subfrmTrainingTimes.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Not sure if it is because of the forum (you should always use the CODE tags when posting code), but you have an extra space (and missing parenthesis). Please try this:
    Code:
    If IsNull(Me.[subfrmTrainingTimes]![TrainingDate]) then
            Me.Date_Taken.Visible = False
    Else
            Me.Date_Taken.Visible = True
    End I
    This will always reference the first record of the subform. To show the latest date taken you would need to sort the subform descending by the TrainingDate.

    Cheers,

  7. #7
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Thanks Gicu, that works great, much appreciated.

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You're very welcome, good luck with your project!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 9
    Last Post: 06-10-2017, 04:52 PM
  2. Replies: 1
    Last Post: 12-09-2015, 10:23 AM
  3. Replies: 6
    Last Post: 03-05-2015, 01:42 PM
  4. Replies: 2
    Last Post: 09-11-2014, 11:37 PM
  5. Display record in unbound text field on form
    By MAABDOLAT in forum Forms
    Replies: 1
    Last Post: 07-25-2012, 06:10 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