K
Katherine
I've got a pretty basic userform with 3 textboxes and a combobox which works ok as is. On clicking submit the entered details are entered into bookmarks in the document.
What i would like to be able to do is set the form so that on clicking submit the details would be inserted into the document and the form would reset itself ready to enter the next set of details.
Doing this isnt a problem, but i need the second set of details entered into the form to be inserted into the 2nd set of bookmarks in the document, same with the third set and so on.
Any clues on how to alter the code to take this into account?
Sub userform_initialize()
txtLocation.SetFocus
cboStatus.List = Array("For Sale", "For Rent")
End Sub
Private Sub cmdSubmit_Click()
With ActiveDocument
.Bookmarks(bmkPrice).Range _
.Text = txtPrice.Value
.Bookmarks("bmkLocation").Range _
.InsertBefore txtLocation
.Bookmarks("bmkAdtext").Range _
.InsertBefore txtAdtext
.Bookmarks("bmkStatus").Range _
.InsertBefore cboStatus
End With
frmEnterDetails.Hide
End Sub
Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim x As Long
On Error GoTo Invalid
x = CLng(txtPrice1.Text)
Exit Sub
Invalid:
MsgBox "Price must be a number. Please don't use any pound signs(£) or other punctuation"
Cancel = True
End Sub
What i would like to be able to do is set the form so that on clicking submit the details would be inserted into the document and the form would reset itself ready to enter the next set of details.
Doing this isnt a problem, but i need the second set of details entered into the form to be inserted into the 2nd set of bookmarks in the document, same with the third set and so on.
Any clues on how to alter the code to take this into account?
Sub userform_initialize()
txtLocation.SetFocus
cboStatus.List = Array("For Sale", "For Rent")
End Sub
Private Sub cmdSubmit_Click()
With ActiveDocument
.Bookmarks(bmkPrice).Range _
.Text = txtPrice.Value
.Bookmarks("bmkLocation").Range _
.InsertBefore txtLocation
.Bookmarks("bmkAdtext").Range _
.InsertBefore txtAdtext
.Bookmarks("bmkStatus").Range _
.InsertBefore cboStatus
End With
frmEnterDetails.Hide
End Sub
Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim x As Long
On Error GoTo Invalid
x = CLng(txtPrice1.Text)
Exit Sub
Invalid:
MsgBox "Price must be a number. Please don't use any pound signs(£) or other punctuation"
Cancel = True
End Sub