Results 1 to 1 of 1

Autonumbers and Userforms...?

Threaded View

  1. #1
    Registered User
    Join Date
    08-30-2007
    Posts
    35

    Question Autonumbers and Userforms...?

    Hello there,

    I am currently trying (failing) to figure out some code to automatically add an autonumber to every new record my user makes using my custom built userform. I would like this number to be a visible column in the table. The table that has all the master data in constantly changes....so it cant be reliant on looking at the number in the above cell/row. Is what im trying to acheive possible?

    Pls see attached workbook for my userform and code.

    Here is a preview of the code i currently use to add a record.

    [code]

    Private Sub btnAddRecord_Click()
    'next empty cell in column A
    Set c = Range("a65536").End(xlUp).Offset(1, 0)
    Application.ScreenUpdating = False 'speed up, hide task
    'write userform entries to database
    c.Value = Me.txtSurname.Value
    c.Offset(0, 1).Value = Me.txtForename.Value
    c.Offset(0, 2).Value = Me.ddlAssignee.Value
    c.Offset(0, 3).Value = Me.txtPersNum.Value
    c.Offset(0, 4).Value = Me.txtStartDate.Value
    c.Offset(0, 5).Value = Me.txtEndDate.Value
    c.Offset(0, 6).Value = Me.ddlDivision.Value
    c.Offset(0, 7).Value = Me.ddlLocation.Value
    c.Offset(0, 8).Value = Me.txtLineManager.Value
    c.Offset(0, 9).Value = Me.txtVCS.Value
    c.Offset(0, 10).Value = Me.ddlHealth.Value
    c.Offset(0, 11).Value = "C"
    'clear the form
    With Me
    .txtSurname.Value = vbNullString
    .txtForename.Value = vbNullString
    .ddlAssignee.Value = vbNullString
    .txtPersNum.Value = vbNullString
    .txtStartDate.Value = vbNullString
    .txtEndDate.Value = vbNullString
    .ddlDivision.Value = vbNullString
    .ddlLocation.Value = vbNullString
    .txtLineManager.Value = vbNullString
    .txtVCS.Value = vbNullString
    .ddlHealth.Value = vbNullString

    End With
    Application.ScreenUpdating = True
    End Sub

    [code/]

    Thanks
    Attached Files Attached Files
    Last edited by thomas.szwed; 11-27-2007 at 07:04 AM.

Thread Information

Users Browsing this Thread

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

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