excel怎么添加、查找和编辑数据记录( 三 )


End If
On Error GoTo ProjectNumberNoMatch
lngMatchRow =Application.Match(Me.txtProjectNumber, wsProjectData.Columns(“A”), )
On Error GoTo
‘找到了项目编号.
Me.lblRecordNofTotal = “在 ” & Str(lngLastRow) &” 行中的第” & Str(lngMatchRow) & ” 行”
lngRow = lngMatchRow
PopulateUserForm lngMatchRow
Exit Sub
ProjectNumberNoMatch:
strMsg = “项目编号 ” & Me.txtProjectNumber& ” 没有找到.”
lngStyle = vbOKOnly + vbInformation
strTitle = “没有找到项目编号”
Beep
intResponse = MsgBox(strMsg, lngStyle,strTitle)
End Sub
‘—————————
‘设置导航按钮
‘—————————
Private Sub lblFirst_Click()
lngRow = 2
PopulateUserForm lngRow
Me.lblRecordNofTotal = “在 ” & Str(lngLastRow) &” 行中的第2行”
End Sub
Private Sub lblFirst_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblFirst.SpecialEffect =fmSpecialEffectSunken
End Sub
Private Sub lblFirst_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
RestoreBackColors
MouseMove “lblFirst”
End Sub
Private Sub lblFirst_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblFirst.SpecialEffect =fmSpecialEffectRaised
End Sub
Private Sub lblLast_Click()
lngRow = lngLastRow
PopulateUserForm lngRow
Me.lblRecordNofTotal = “在 ” & Str(lngLastRow) &” 行中的最后一行”
End Sub
Private Sub lblLast_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblLast.SpecialEffect =fmSpecialEffectSunken
End Sub
Private Sub lblLast_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
RestoreBackColors
MouseMove “lblLast”
End Sub
Private Sub lblLast_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblLast.SpecialEffect =fmSpecialEffectRaised
End Sub
Private Sub lblNext_MouseDown(ByValButton As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y AsSingle)
Me.lblNext.SpecialEffect =fmSpecialEffectSunken
MouseDownNext
End Sub
Private Sub lblNext_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
RestoreBackColors
MouseMove “lblNext”
End Sub
Private Sub lblNext_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblNext.SpecialEffect =fmSpecialEffectRaised
blnMouseDown = False
End Sub
Private Sub lblPrev_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblPrev.SpecialEffect =fmSpecialEffectSunken
MouseDownPrevious
End Sub
Private Sub lblPrev_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
RestoreBackColors
MouseMove “lblPrev”
End Sub
Private Sub lblPrev_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X AsSingle, ByVal Y As Single)
Me.lblPrev.SpecialEffect =fmSpecialEffectRaised
blnMouseDown = False
End Sub
Private Sub MouseDownNext()
blnMouseDown = True
Do While blnMouseDown = True
Select Case lngRow
Case lngLastRow
lngRow = lngLastRow
Case Else
lngRow = lngRow + 1
‘到达最后一行
If lngRow >= lngLastRow ThenlngRow = lngLastRow

猜你喜欢