Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Middelburg, Zeeland, Netherlands
    Posts
    165
    Thanks
    20
    Thanked 2 Times in 2 Posts

    name of day (2000)

    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

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: name of day (2000)

    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

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: name of day (2000)

    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
    Regards,

    Gary
    (It's been a while!)

  4. #4
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Middelburg, Zeeland, Netherlands
    Posts
    165
    Thanks
    20
    Thanked 2 Times in 2 Posts

    Re: name of day (2000)

    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

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: name of day (2000)

    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.

  6. #6
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: name of day (2000)

    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
    Regards,

    Gary
    (It's been a while!)

  7. #7
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Middelburg, Zeeland, Netherlands
    Posts
    165
    Thanks
    20
    Thanked 2 Times in 2 Posts

    Re: name of day (2000)

    thnx all, that helped, working like a charm
    CU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •