+ Reply to Thread
Results 1 to 4 of 4

Add New Field in USER Form

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-06-2015
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    520

    Add New Field in USER Form

    Dear all

    I have this code given, it works fine but i need to add 2 more fields
    cmb_staff
    txt_date
    I try to put then in the front as

    With ThisWorkbook.Sheets("main")
    NextRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    .Cells(NextRow, 1) = cmb_staff
    .Cells(NextRow, 2 = txt_date
    .Cells(NextRow, 3 ) = cmb_city
    .Cells(NextRow,4) = cmb_nature

    However, when i enter the first time, was go to the first row rather then at the last one, 2nd enter it replaced out my record 2nd row record.

    How can i fix it

    Private Sub Btn_close_Click()

    Dim Company As String
    Dim NextRow As Long

    Company = txt_company

    With ThisWorkbook.Sheets("main")
    NextRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    .Cells(NextRow, 1) = cmb_city
    .Cells(NextRow, 2) = cmb_nature
    .Cells(NextRow, 3) = txt_company
    .Cells(NextRow, 4) = txt_contact
    .Cells(NextRow, 5) = txt_title
    .Cells(NextRow, 6) = txt_tel
    .Cells(NextRow, 7) = txt_mail
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 7), Address:="Mailto://" & txt_mail
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 8), Address:="http://" & txt_web
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 9), Address:="http://" & txt_shared
    End With

    Unload USER

    MsgBox Company & " has been added to the Record", 0, "Completed"
    End Sub

    Appreciated your help

    Eric
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,969

    Re: Add New Field in USER Form

    Your post does not comply with Rule 2 of our Forum Rules: Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    This thread should receive no further responses until this moderation request is fulfilled.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    12-06-2015
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    520

    Re: Add New Field in USER Form

    Dear all

    Sorry, i am not familar with the code


    Dear all

    I have this code given, it works fine but i need to add 2 more fields
    cmb_staff
    txt_date
    I try to put then in the front as

     
    With ThisWorkbook.Sheets("main")
    NextRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    .Cells(NextRow, 1) = cmb_staff
    .Cells(NextRow, 2 = txt_date 
    .Cells(NextRow, 3 ) = cmb_city
    .Cells(NextRow,4) = cmb_nature
    
    However, when i enter the first time, was go to the first row rather then at the last one, 2nd enter it replaced out my record 2nd row record.

    How can i fix it

    Private Sub Btn_close_Click()

    Dim Company As String
    Dim NextRow As Long

    Company = txt_company

     With ThisWorkbook.Sheets("main")
    NextRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    .Cells(NextRow, 1) = cmb_city
    .Cells(NextRow, 2) = cmb_nature
    .Cells(NextRow, 3) = txt_company
    .Cells(NextRow, 4) = txt_contact.Cells(NextRow, 5) = txt_title
    .Cells(NextRow, 6) = txt_tel
    .Cells(NextRow, 7) = txt_mail
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 7), Address:="Mailto://" & txt_mail
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 8), Address:="http://" & txt_web
    .Hyperlinks.Add Anchor:=.Cells(NextRow, 9), Address:="http://" & txt_shared
    End With
    
    Unload USER
    
    MsgBox Company & " has been added to the Record", 0, "Completed"
    End Sub
    Appreciated your help

    Eric

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,969

    Re: Add New Field in USER Form

    I don't know why you reposted everything in a new post, and in yellow, which is quite unreadable. In your first post, underneath the post click Edit Post. Then add the CODE tags for your code, and then Save. I do this for new members but you have been here 3 years with over 200 posts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 08-22-2018, 06:42 PM
  2. [SOLVED] Can user form fields be depenent upon the answer to another field?
    By aliciaward1001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2017, 09:43 AM
  3. [SOLVED] user form overlabps the records if one field is not filled
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2015, 01:13 PM
  4. [SOLVED] How to Restrict User To Select One Field in a continuous form
    By :) Sixthsense :) in forum Access Tables & Databases
    Replies: 6
    Last Post: 03-02-2015, 01:28 AM
  5. Text box field reference in a user form
    By SinGin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2010, 09:52 PM
  6. Text field visible property on user form
    By JChandler22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2010, 02:44 PM
  7. User Form field inserts wrong date format
    By simjambra in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-26-2009, 04:09 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1