Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Access Form - Enter text day name (Sun) based on another field

Posted on 2008-11-11
2
Medium Priority
?
186 Views
Last Modified: 2013-11-28
I have a form that includes a date txtDate.  I would like the next field txtDay to be the three letter name for txtDate.  So, if txtDate is 11/11/2008 I would like txtDay to autopopulate with Tue.

I have tried the attached code as an event in the AfterUpdate.

Any ideas?

Thank you in advance.
Private Sub txtDate_AfterUpdate()
       If Format([txtDate], "w") = 1 Then
       Me.txtDay = "Sun"
        ElseIf Format([txtDate], "w") = 2 Then
       Me.txtDay = Mon
        ElseIf Format([txtDate], "w") = 3 Then
       Me.txtDay = Tue
        ElseIf Format([txtDate], "w") = 4 Then
       Me.txtDay = Wed
        ElseIf Format([txtDate], "w") = 5 Then
       Me.txtDay = Thu
        ElseIf Format([txtDate], "w") = 6 Then
       Me.txtDay = Fri
        ElseIf Format([txtDate], "w") = 7 Then
       Me.txtDay = Sat
       End If
End Sub

Open in new window

Test.mdb
0
Comment
Question by:Scamquist
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 22931418
=format(datefield,"ddd")
0
 
LVL 1

Author Closing Comment

by:Scamquist
ID: 31515546
I wanted to keep txtDay as text.  I thought a format command would force me to change it to a date field.  Your answer was about as concise and easy to apply as possible.  Thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question