|
-
Jan 16th, 2006, 09:41 PM
#1
Thread Starter
Addicted Member
Auto Increment...please help..
Dear Experts,
I am creating a word document with VBA form...what should I add to this following codes to create an auto increment...for instance, I have "No", "Name", "Address", etc...when I click on "Add Row" button, it will add new rows for those fields BUT...only the number is automatically counted such as 1,2,3 and so on...here is the codes:
VB Code:
Private Sub cmd_AddRow_Click()
Dim newRow As Row
Dim myTable As Table
'Add row:
Set myTable = ActiveDocument.Tables(1)
Set newRow = myTable.Rows.Add
'Insert UserForm textbox's text:
newRow.Cells(1).Range.InsertAfter Text:=txt_number.Text
newRow.Cells(2).Range.InsertAfter Text:=txt_num.Text
newRow.Cells(3).Range.InsertAfter Text:=txt_floor.Text
newRow.Cells(4).Range.InsertAfter Text:=txt_rep.Text
newRow.Cells(5).Range.InsertAfter Text:=txt_oldno.Text
newRow.Cells(6).Range.InsertAfter Text:=txt_newno.Text
newRow.Cells(7).Range.InsertAfter Text:=txt_remark.Text
'Clear textboxes:
Me.txt_number.Text = vbNullString
Me.txt_num.Text = vbNullString
Me.txt_floor.Text = vbNullString
Me.txt_rep.Text = vbNullString
Me.txt_oldno.Text = vbNullString
Me.txt_newno.Text = vbNullString
Me.txt_remark.Text = vbNullString
Application.ScreenRefresh
End Sub
What codes should I add to have an auto increment..???...please..????
Thanks a lot for your helps...
Jennifer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|