Results 1 to 2 of 2
  1. #1
    ccordner is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    65

    vba to write a record

    Hi

    I'm quite new to programming vba in access, but I have two fields (txtDateFrom and txtDateTo) on a form. If the txtDateTo is empty, I just want to save the record to the table.



    If there is a value in it, I want to save it and then create extra records for each day between the two dates (inclusive).

    I have got as far as the code below, but don't really know where to go form here!

    Thanks
    Chris

    Code:
    Private Sub cmdAddLeave_Click()
    DoCmd.RunCommand acCmdSaveRecord
    If Not Len(Me.Me.txtDateTo & vbNullString) = 0 Then
        
        For LeaveDate = Me.txtDateFrom.Value + 1 To Me.txtDateTo.Value
            
        Next
    Else
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This is doing something a little different, but the recordset portion of it is a way of doing what you want.

    http://www.baldyweb.com/MultiselectAppend.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Write record to table
    By NISMOJim in forum Programming
    Replies: 10
    Last Post: 12-04-2011, 02:22 PM
  2. Replies: 3
    Last Post: 02-01-2011, 07:15 AM
  3. How Do I Write This Query?
    By TxTcher in forum Forms
    Replies: 8
    Last Post: 08-13-2010, 01:50 PM
  4. Replies: 1
    Last Post: 06-24-2010, 08:08 AM
  5. write a query how to???
    By flamingo in forum Queries
    Replies: 0
    Last Post: 01-13-2009, 03:57 AM

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