K
Katherine
Part of the code for a simple userform: (see below for query)
~~~~~~~~~~~~~~~~~~~~
Private Sub cmdNext_Click()
nSet = txtBox.Value
If optRent = True Then
strSaleRent = "For Rent"
Else:
strSaleRent = "For Sale"
End If
With ActiveDocument
.Bookmarks("bmkStatus" & nSet).Range _
.InsertBefore strSaleRent
.Bookmarks("bmkPrice" & nSet).Range _
.InsertBefore txtPrice
.Bookmarks("bmkAdtext" & nSet).Range _
.InsertBefore txtAdtext
.Bookmarks("bmkDistrict" & nSet).Range _
.InsertBefore txtDistrict
End With
If strSaleRent = "For Rent" Then strTenure = "Rental"
If strSaleRent = "For Sale" Then strTenure = "Freehold"
ActiveDocument.Bookmarks("bmkTenure" & nSet).Range _
.InsertBefore strTenure
txtBox = Null
txtDistrict = Null
optSale = True
txtPrice = Null
txtAdtext = Null
txtPrice.Enabled = False
txtAdtext.Enabled = False
lblPrice.Enabled = False
lblAdtext.Enabled = False
End Sub
~~~~~~~~~~~~~~~~~~~
What I need to do is give a visual representation of which box numbers have
already been submitted so I've created a series of labels, corresponding to
the possible box numbers called lblBox1, lblBox2 etc, the idea being that
once that box number has been used the label will become greyed out to show
this.
The box number is the value entered into txtBox and the nSet variable has
the same value as this text box, so I could do this with the following lines:
If nSet = 1 then lblBox1.enabled = False
If nSet = 2 then lblBox2.enabled = False etc
Problem is, potentially nSet could be anything from 1 to 48 and writing that
out 48 times seems rather clumsy. Des anyone have any suggestions as how I
could tidy the code for this up?
~~~~~~~~~~~~~~~~~~~~
Private Sub cmdNext_Click()
nSet = txtBox.Value
If optRent = True Then
strSaleRent = "For Rent"
Else:
strSaleRent = "For Sale"
End If
With ActiveDocument
.Bookmarks("bmkStatus" & nSet).Range _
.InsertBefore strSaleRent
.Bookmarks("bmkPrice" & nSet).Range _
.InsertBefore txtPrice
.Bookmarks("bmkAdtext" & nSet).Range _
.InsertBefore txtAdtext
.Bookmarks("bmkDistrict" & nSet).Range _
.InsertBefore txtDistrict
End With
If strSaleRent = "For Rent" Then strTenure = "Rental"
If strSaleRent = "For Sale" Then strTenure = "Freehold"
ActiveDocument.Bookmarks("bmkTenure" & nSet).Range _
.InsertBefore strTenure
txtBox = Null
txtDistrict = Null
optSale = True
txtPrice = Null
txtAdtext = Null
txtPrice.Enabled = False
txtAdtext.Enabled = False
lblPrice.Enabled = False
lblAdtext.Enabled = False
End Sub
~~~~~~~~~~~~~~~~~~~
What I need to do is give a visual representation of which box numbers have
already been submitted so I've created a series of labels, corresponding to
the possible box numbers called lblBox1, lblBox2 etc, the idea being that
once that box number has been used the label will become greyed out to show
this.
The box number is the value entered into txtBox and the nSet variable has
the same value as this text box, so I could do this with the following lines:
If nSet = 1 then lblBox1.enabled = False
If nSet = 2 then lblBox2.enabled = False etc
Problem is, potentially nSet could be anything from 1 to 48 and writing that
out 48 times seems rather clumsy. Des anyone have any suggestions as how I
could tidy the code for this up?