none
Set a Field Value RRS feed

  • Question

  • Hello,

    I have (3) fields in a table...

    Field1 = Title

    Field2 = Bldg

    Filed3 = Project

    In my form, Field1 is simply text that is typed.  Field2 is a combo box identifying buildings.  I would like Field3 = [Bldg] & " " & [Title].  Is this best accomplished by an "after update" on Field2 or is there a more efficient method?


    Thanks PU_RJF

    Wednesday, March 18, 2020 8:14 PM

Answers

  • One option is to set the Data Type of Project to Calculated, with the formula =[Bldg] & " " & [Title]

    Another option is to delete the Project field from the table. Instead, create a query based on the table.

    Add Title and Bldg to the query grid, and next to it, create a calculated column:

    Project: [Bldg] & " " & [Title]

    Save the query, and use it as record source for forms and reports.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by PU_RJF Friday, March 20, 2020 11:33 AM
    Wednesday, March 18, 2020 9:00 PM
  • Since the Field3 (Project) field on your form is dependent upon what is typed in the Title field and what is selected in the Blding field, if you do not want to actually store that value in the tables Project field, then in the Record Source of the Field3 textbox on your form enter:

    =IIf(IsNull([Blding]),Null,[Bldg] & " " & [Title])

    Field3 should then show whatever [Bldg] & " " & [Title] is if [Blding] is not null

    Next, in the Blding field After Update Event enter VBA code:

    Me.Field3.ReCalc

    That should recalculate Field3 after the Blding combo box entry is selected.

    If you want to store the [Bldg] & " " & [Title] value in the Project field, then bind the Field3 textbox Control Source to the tables Project field and then in the [Blding] After Update Event enter the VBA code:

    Me.Field3 = Me.Bldg & " " & Me.Title

    This will set the Field3 value to whatever [Bldg] & " " & [Title] is.


    • Edited by Lawrence Ellefson Wednesday, March 18, 2020 11:08 PM
    • Marked as answer by PU_RJF Friday, March 20, 2020 11:33 AM
    Wednesday, March 18, 2020 11:07 PM

All replies

  • One option is to set the Data Type of Project to Calculated, with the formula =[Bldg] & " " & [Title]

    Another option is to delete the Project field from the table. Instead, create a query based on the table.

    Add Title and Bldg to the query grid, and next to it, create a calculated column:

    Project: [Bldg] & " " & [Title]

    Save the query, and use it as record source for forms and reports.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by PU_RJF Friday, March 20, 2020 11:33 AM
    Wednesday, March 18, 2020 9:00 PM
  • Since the Field3 (Project) field on your form is dependent upon what is typed in the Title field and what is selected in the Blding field, if you do not want to actually store that value in the tables Project field, then in the Record Source of the Field3 textbox on your form enter:

    =IIf(IsNull([Blding]),Null,[Bldg] & " " & [Title])

    Field3 should then show whatever [Bldg] & " " & [Title] is if [Blding] is not null

    Next, in the Blding field After Update Event enter VBA code:

    Me.Field3.ReCalc

    That should recalculate Field3 after the Blding combo box entry is selected.

    If you want to store the [Bldg] & " " & [Title] value in the Project field, then bind the Field3 textbox Control Source to the tables Project field and then in the [Blding] After Update Event enter the VBA code:

    Me.Field3 = Me.Bldg & " " & Me.Title

    This will set the Field3 value to whatever [Bldg] & " " & [Title] is.


    • Edited by Lawrence Ellefson Wednesday, March 18, 2020 11:08 PM
    • Marked as answer by PU_RJF Friday, March 20, 2020 11:33 AM
    Wednesday, March 18, 2020 11:07 PM