C
Cameron
Hi all and sundry,
Part `A` - Have the following code on a UserForm, need to know how I can
make this more efficient (if required).
----------------------------------
Private Sub CancelButton_Click()
Me.Hide
Sheet1.ShowButtons
End Sub
----------------------------------
Private Sub ContinueButton_Click()
Select Case Len(TextBox1.Text)
Case 0
MsgBox "Information Required - Doctors Name." & vbCrLf & "This
field cannot remain empty.", vbInformation, "Missing Data!"
TextBox1.SetFocus
Exit Sub
End Select
Select Case Len(TextBox2.Text)
Case 0
MsgBox "Information Required - Brief Detail." & vbCrLf & "This
field cannot remain empty.", vbInformation, "Missing Data!"
TextBox2.SetFocus
Exit Sub
End Select
Select Case Len(TextBox3.Text)
Case 0
MsgBox "Information Required - Address Details." & vbCrLf &
"This field cannot remain empty.", vbInformation, "Missing Data!"
TextBox3.SetFocus
Exit Sub
Case Else
Select Case Len(TextBox4.Text)
Case 0
Resp1 = MsgBox("Information Required - Address Details."
& vbCrLf & "Are you sure this line is to be empty?", vbYesNo, "Missing
Data!")
If Resp1 = vbNo Then
TextBox4.SetFocus
Exit Sub
End If
Case Else
Select Case Len(TextBox5.Text)
Case 0
Resp1 = MsgBox("Information Required - Address
Details." & vbCrLf & "Are you sure this line is to be empty?", vbYesNo,
"Missing Data!")
If Resp1 = vbNo Then
TextBox5.SetFocus
Exit Sub
End If
End Select
End Select
End Select
Resp2 = MsgBox("Please confirn the following details:" & vbTab & vbCrLf
& _
"Doctors Name:" & vbTab & TextBox1.Text & "." & vbTab & vbCrLf & _
"Brief Detail:" & vbTab & TextBox2.Text & "." & vbTab & vbCrLf & _
"Address Details:" & vbCrLf & _
vbTab & vbTab & TextBox3.Text & "." & vbCrLf & _
vbTab & vbTab & TextBox4.Text & "." & vbCrLf & _
vbTab & vbTab & TextBox5.Text & ".", vbYesNo, "Confirm Details
Entered.")
Select Case Resp2
Case vbYes
MsgBox "ADD the Doctor here & now."
Case vbNo
MsgBox "Will not Proceede with ADD"
End Select
Me.Hide
End Sub
----------------------------------
Private Sub UserForm_Initialize()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
----------------------------------
Part `B` - At the point where it says "ADD the Doctor here & now.", I intend
to add the details provided and enter them onto the spreadsheet.
The area where I wold like to insert this data is in a Named region.
The question is what code do I need to insert a row into the DoctorsTable
and sort the region.
Many thanks for any assistance.
Cheers,
Cameron
Part `A` - Have the following code on a UserForm, need to know how I can
make this more efficient (if required).
----------------------------------
Private Sub CancelButton_Click()
Me.Hide
Sheet1.ShowButtons
End Sub
----------------------------------
Private Sub ContinueButton_Click()
Select Case Len(TextBox1.Text)
Case 0
MsgBox "Information Required - Doctors Name." & vbCrLf & "This
field cannot remain empty.", vbInformation, "Missing Data!"
TextBox1.SetFocus
Exit Sub
End Select
Select Case Len(TextBox2.Text)
Case 0
MsgBox "Information Required - Brief Detail." & vbCrLf & "This
field cannot remain empty.", vbInformation, "Missing Data!"
TextBox2.SetFocus
Exit Sub
End Select
Select Case Len(TextBox3.Text)
Case 0
MsgBox "Information Required - Address Details." & vbCrLf &
"This field cannot remain empty.", vbInformation, "Missing Data!"
TextBox3.SetFocus
Exit Sub
Case Else
Select Case Len(TextBox4.Text)
Case 0
Resp1 = MsgBox("Information Required - Address Details."
& vbCrLf & "Are you sure this line is to be empty?", vbYesNo, "Missing
Data!")
If Resp1 = vbNo Then
TextBox4.SetFocus
Exit Sub
End If
Case Else
Select Case Len(TextBox5.Text)
Case 0
Resp1 = MsgBox("Information Required - Address
Details." & vbCrLf & "Are you sure this line is to be empty?", vbYesNo,
"Missing Data!")
If Resp1 = vbNo Then
TextBox5.SetFocus
Exit Sub
End If
End Select
End Select
End Select
Resp2 = MsgBox("Please confirn the following details:" & vbTab & vbCrLf
& _
"Doctors Name:" & vbTab & TextBox1.Text & "." & vbTab & vbCrLf & _
"Brief Detail:" & vbTab & TextBox2.Text & "." & vbTab & vbCrLf & _
"Address Details:" & vbCrLf & _
vbTab & vbTab & TextBox3.Text & "." & vbCrLf & _
vbTab & vbTab & TextBox4.Text & "." & vbCrLf & _
vbTab & vbTab & TextBox5.Text & ".", vbYesNo, "Confirm Details
Entered.")
Select Case Resp2
Case vbYes
MsgBox "ADD the Doctor here & now."
Case vbNo
MsgBox "Will not Proceede with ADD"
End Select
Me.Hide
End Sub
----------------------------------
Private Sub UserForm_Initialize()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
----------------------------------
Part `B` - At the point where it says "ADD the Doctor here & now.", I intend
to add the details provided and enter them onto the spreadsheet.
The area where I wold like to insert this data is in a Named region.
and other Named regions within this areDoctorsTable = 'Extra Tables'!$C$13:$E$20
Doctors = 'Extra Tables'!$C$13:$C$20
DoctorsArray = 'Extra Tables'!$C$13:$D$20
The question is what code do I need to insert a row into the DoctorsTable
and sort the region.
Many thanks for any assistance.
Cheers,
Cameron