• name of day (2000)

    Author
    Topic
    #377821

    In a table I have to fill in a date.
    In another field called day I want the name of the day that belongs to the date entered in the other field.
    How do I do this?
    TIA
    George

    Viewing 1 reply thread
    Author
    Replies
    • #623294

      There should be no need to put this in a table as the format function will translate a date into a day for you.
      However if you insist in putting the day into a field in a table then use the format function as follows:

      Field = Format(YourDateField,”dddd”)

      HTH
      Pat

    • #623296

      Create an update query against the table you want to insert the day of the week as follows:

      Assume the Table with the Date field in it is called Table 1.
      1. Insert another field in table 1 called DayOfWeek
      2. Create a New Query and show table Table 1 (or your table with the Date field in it)
      3. Select the query type as an Update Query
      4. In the Field of the query input DayOfWeek (The field to be updated)
      5. Table is the Table being updated (Table 1 for this example)
      6. In the Update To field, insert Format([DATE],’dddd’)
      Run the query.

      The weekday will be inserted in the DayOfWeek field

      HTH

      • #623508

        Gary, thanx.
        So far, so good.
        But now I have to manually run the query and I want to automate that in a form.
        I fill in the Date-field en on leaving, tabbing to the next field I want this field to get updated.
        How? TIA, George

        • #623513

          I guess there is some confusion here about “field”.
          By a field, we usually mean a column in a table (or query). On a form, we use a text box to fill in a field.

          In your case, you don’t need a field in the table to hold the name of the day. You can create a new text box on the form bound to the date field; the easiest way is to drag the field from the Field List window to the form (in design view). Alternatively, create a text box using the Toolbox, and set its Control Source property to the name of the date field. Set the Format property of the text box to dddd, and set the Locked property of this text box to True.
          If you enter a date in the other text box and tab out of it, the new text box will display the name of the day.

        • #623520

          I have to agee with Hans here. I assumed you were trying to fill in a field in a table. However, if the table contains the date, then why use up unnecessary space in the table.

          If in a Form, you can do as Hans said with the textbox.

          However, If you really want to launch the query…

          You could use the on change event of the field where you fill in the date to launch the query using the following code:

          docmd.SetWarnings WarningsOff ‘Turn off System Warnings
          DoCmd.OpenQuery “QueryName” ‘Run Update Query
          Refresh ‘Refresh Screen to see the new data
          docmd.SetWarnings WariningsOn ‘Turn System Warnings On

          This will run the update query each time the data in the date field is changed assuming you are entering the date data.

          HTH

    Viewing 1 reply thread
    Reply To: name of day (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: