Results 1 to 6 of 6
  1. #1
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Entering Today's Date

    Hello everybody,


    I do have a Daily Cotton Auction database, in which cotton purchases are entered on auction basis. I have a table ‘tblCottonMarketDate, which has DateID (Auto number)& MktDate (Date)as fields.




    At present maket date is entered manually through a Form. What I want is, when the Switchboard opens, a message box should appear asking ‘ Do you want to enter today’s Date?’ If Yes button is clicked, system date should be entered in the table. If again the database is opened on the same date, a message box should appear stating, ‘Date already entered’ with OK button.


    Please help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You want to automatically create record and enter date, eliminating the manual entry form? Need another field in the table for DateEntered. So code in the Switchboard open event would check table if any DateEnter matches current date and if does tell user 'Date already entered', otherwise prompt user for date, then use SQL INSERT statement to enter new record with the market date and current date.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Automatic date entry

    Dear June7,

    Can you please post me the SQL Insert Statement. I presume the IIf function has to be used.

    Alex

  4. #4
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi Alex,

    presuming your table with the dates is named tblMarketDates:

    Code:
    Dim rst As New ADODB.Recordset
        
        If DLookup("DateID", "tblMarketDates", "MktDate = #" & Date & "#") > 1 Then
            MsgBox "Sorry the current date is already inserted"
        Else
            rst.Open "select Mktdate from tblMarketDates", CurrentProject.Connection, adOpenKeyset, adLockPessimistic
            With rst
                .AddNew
                !MktDate = Date
                .Update
                .Close
            End With
        End If
        Set rst = Nothing
    grNG

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I may have misunderstood part of what you want to do. You ask user if they want to enter current date - what should happen if they say no, just quit? I thought you wanted to allow them to enter an alternate date. If not, then my suggestion for a DateEnter field is not relevant and NoellaG's code should serve.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Inserting Current Date

    Thank U NoellaG,

    Your solution worked fine. Thanks June7 for your response.

    Alex

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

Similar Threads

  1. If problem-comparing field+1735<Today()
    By Madmax in forum Access
    Replies: 6
    Last Post: 06-23-2011, 01:38 PM
  2. Query to display ONLY entries from today
    By Juan4412 in forum Queries
    Replies: 9
    Last Post: 01-15-2011, 05:34 PM
  3. Replies: 2
    Last Post: 01-12-2011, 12:00 AM
  4. Set Calendar to default to today's date
    By RickM in forum Access
    Replies: 1
    Last Post: 02-22-2009, 04:51 AM
  5. query date that is five years older than today
    By cpsummer in forum Queries
    Replies: 2
    Last Post: 09-26-2007, 02:31 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