Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Entry (2002)

    Hello All,
    I have a form that requires the user to select the month from one control and the year from another. The end result is that there are two entries created into a table with that month and year. What I want to do now is to sort the month/year display within the form but there are two fields. How can I create a single entry in the table for the month/year or display the month/year in order? Hopefully not too confusing!

    Thanks,
    Mark

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

    Re: Date Entry (2002)

    You can create a query based on the table. Put the month field to the right of the year field in the query grid, and sort on both fields. The records will be sorted by year, and within a year by month. Use the query as record source for forms and reports.

  3. #3
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Entry (2002)

    Mark,

    Are you adding your records programmatically? If not, I'm afraid the only way to merge the two fields into one field on your table is to run an update query. If you are using code to add records, I would assume the following (to fuel my example)
    Month combo box name: cboMonth
    Year combo box name: cboYear

    Private Sub CmdAdd_Click()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset

    On Error GoTo ErrHandler
    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblNAME")

    With rst

    rst.AddNew
    rst!DATE = cboMonth & "/" cboYear
    rst.Update
    rst.Close

    End With

    ExitHandler:
    On Error Resume Next
    rst.Close
    Set rst = Nothing
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler

    End Sub

    Be sure to format your field as a date that will accomodate the data entry.
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What's more, you deserve to be hacked." -Richard Clarke

  4. #4
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Entry (2002)

    Thanks, I tried something simple and it worked.

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Entry (2002)

    Thanks Hans.

Posting Permissions

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