Private Sub CommandButton2_Click()
Dim newSheetName As String, strPrefix As String
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")
Sheets("Database").Activate
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If Trim(Me.TextBox0.Value) = "" Then
Me.TextBox00.Value = ""
Me.TextBox0.SetFocus
Me.Hide
MsgBox "Please Enter."
Me.Show
Exit Sub
End If
If WorksheetFunction.CountIf(ws.Range("A3", ws.Cells(iRow, 1)), _
Me.TextBox0.Value) >= 1 Then
Me.TextBox00.Value = ""
Me.TextBox0.Value = ""
Me.TextBox0.SetFocus
Me.Hide
MsgBox "Duplicate Found", vbCritical
Me.Show
Exit Sub
End If
If Trim(Me.TextBox00.Value) = "" Then
Me.TextBox00.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox000.Value) = "" Then
Me.TextBox000.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox0000.Value) = "" Then
Me.TextBox0000.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
'confirm Create New Worksheet
If MsgBox("Create New Worksheet " & vbCrLf & _
"" & TextBox0, vbYesNo, "Notification") = vbNo Then
Exit Sub
Else
MsgBox "New Worksheet " & TextBox0 & vbCrLf & _
"Create Successfully"
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
'Create New Worksheet with Member ID
newSheetName = Me.TextBox0
strPrefix = newSheetName
Sheet4.Copy Before:=Sheet4
With ActiveSheet
On Error GoTo DupName
.Name = newSheetName
On Error GoTo 0
End With
Exit Sub
DupName:
newSheetName = strPrefix & (Val(Replace(newSheetName, strPrefix, vbNullString, 1, 1)) + 1)
Resume
Set ws = Worksheets("newSheetName")
Sheets("newSheetName").Activate
End If
End If
End Sub
Private Sub CommandButton3_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = ActiveSheet
Dim wsd As Worksheet
Set wsd = Worksheets("Database")
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox2.Value) = "" Then
Me.TextBox2.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox3.Value) = "" Then
Me.TextBox3.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.ComboBox4.Value) = "" Then
Me.ComboBox4.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox5.Value) = "" Then
Me.TextBox5.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.ComboBox6.Value) = "" Then
Me.ComboBox6.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox7.Value) = "" Then
Me.TextBox7.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.ComboBox8.Value) = "" Then
Me.ComboBox8.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox9.Value) = "" Then
Me.TextBox9.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
If Trim(Me.TextBox10.Value) = "" Then
Me.TextBox10.SetFocus
Me.Hide
MsgBox "Please enter"
Me.Show
Exit Sub
End If
'copy the data to the newSheetName
ws.Cells(1, 1).Value = Me.TextBox0.Value
ws.Cells(1, 2).Value = Me.TextBox00.Value
ws.Cells(1, 3).Value = Me.TextBox000.Value
ws.Cells(1, 4).Value = Me.TextBox0000.Value
ws.Cells(1, 5).Value = Me.TextBox1.Value
ws.Cells(1, 6).Value = Me.TextBox2.Value
ws.Cells(1, 7).Value = Me.TextBox3.Value
ws.Cells(1, 8).Value = Me.ComboBox4.Value
ws.Cells(1, 9).Value = Me.TextBox5.Value
ws.Cells(1, 10).Value = Me.ComboBox6.Value
ws.Cells(1, 11).Value = Me.TextBox7.Value
ws.Cells(1, 12).Value = Me.ComboBox8.Value
ws.Cells(1, 13).Value = Me.TextBox9.Value
ws.Cells(1, 14).Value = Me.TextBox10.Value
ws.Cells(1, 15).Value = Me.TextBox11.Value
iRow = wsd.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
Sheet3.Hyperlinks.Add _
Anchor:=wsd.Cells(iRow, 1), _
Address:=ws.Cells(1, 1).Activate, _
TextToDisplay:=Me.TextBox0.Value
'copy the data to the Database
wsd.Cells(iRow, 1).Value = UCase(Me.TextBox0.Value)
wsd.Cells(iRow, 2).Value = UCase(Me.TextBox000.Value)
wsd.Cells(iRow, 3).Value = UCase(Me.TextBox0000.Value)
wsd.Cells(iRow, 4).Value = Me.TextBox00.Value
wsd.Cells(iRow, 5).Value = Me.TextBox1.Value
wsd.Cells(iRow, 6).Value = Me.TextBox2.Value
wsd.Cells(iRow, 7).Value = Me.TextBox3.Value
wsd.Cells(iRow, 8).Value = Me.ComboBox4.Value
wsd.Cells(iRow, 9).Value = Me.TextBox5.Value
wsd.Cells(iRow, 10).Value = Me.ComboBox6.Value
wsd.Cells(iRow, 11).Value = Me.TextBox7.Value
wsd.Cells(iRow, 12).Value = Me.ComboBox8.Value
wsd.Cells(iRow, 13).Value = Me.TextBox9.Value
wsd.Cells(iRow, 14).Value = Me.TextBox10.Value
wsd.Cells(iRow, 15).Value = Me.TextBox11.Value
Sheets("Login").Activate
Unload MemberData
'confirm data transferred
MsgBox "Member ID.:- " & TextBox0 & vbCrLf & _
"Family Name:- " & TextBox000 & vbCrLf & _
"Data Transferred Successfully" & vbCrLf & _
"", vbInformation, "Data transfer"
End Sub
Bookmarks