Results 1 to 4 of 4
  1. #1
    Only4Access is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    38

    Arrow INSERT INTO from multi line text box

    Hi Experts,

    I have a table tblAccounts. ID (Autonumber), AccountNumber, TransDate, (Default as Date()), TransAmount, EntryDateTime (default as Now())

    I have set up a form (frmTemp) with text box (Text1) with multi line enabled. In properties 'New Line in Field' so people will enter or copy paste from note pad. As we know will have multiple lines or just one line.

    I have also created a form for tblAccount (frmAccounts) default view as Continuous Forms.

    What I am trying to do is when click on a button;



    1. Loop through each line in Text1 & insert each line in AccountNumber field in tblAccounts. TransDate: Date(), TransAmount: $0, EntryDateTime: Now()
    2. Close this form (frmTemp) & open frmAccounts

    If Text1 has 5 lines Insert these 5 accounts in tblAccount with other field it's default values.

    Thank you for your help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Maybe something like:

    Dim aryAcct As Variant
    Dim i As Integer
    aryAcct = Split(Me.Text1, vbCrLf)
    For i = 0 to UBound(aryAcct) - 1
    CurrentDb.Execute "INSERT INTO tblAccounts(AccountNumber, TransDate, TransAmount, EntryDateTime) VALUES('" & aryAcct(i) & "', Date(), 0, Now())"
    Next
    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
    Only4Access is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    38
    Thank you June7 for you reply.

    This one works great, but always skip last line in text box. When I remove -1 in ubound works well.

    Is that OK or should i do something else?

    Thank you June7.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That surprises me but as long as you get what you need.
    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.

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

Similar Threads

  1. Replies: 7
    Last Post: 06-04-2013, 01:10 PM
  2. Replies: 2
    Last Post: 05-22-2012, 03:29 PM
  3. Replies: 6
    Last Post: 04-07-2011, 12:33 PM
  4. Querying Multi Line Text Box in MS Access Forms
    By spindlebeakin10 in forum Queries
    Replies: 5
    Last Post: 12-09-2010, 05:50 PM
  5. Insert Into Statement with Line Numbers
    By Cheshire101 in forum Programming
    Replies: 1
    Last Post: 10-11-2010, 02:53 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