Hi again,
I got these code for searching surname in the database. The result is displayed in the data sheet view.
Private Sub GoBtnSurname_Click()
Dim LookforSurname As String
If IsNull(Me!FindSurname) Then
Beep
MsgBox "You Must Enter a Value in the Find Surname Field", [vbOKOnly]
DoCmd.GoToControl ("FindSurname"
Exit Sub
Else
DoCmd.OpenForm ("frmDatasheet"
LookforSurname = Me!FindSurname
DoCmd.GoToControl ("Surname"
DoCmd.RunCommand acCmdSortAscending
DoCmd.FindRecord LookforSurname, , , , , True
End If
While Screen.ActiveForm.Name = "frmDatasheet"
DoEvents
Wend
DoCmd.GoToControl "Case_Num"
DoCmd.RunCommand acCmdSortAscending
DoCmd.FindRecord Common.newCaseNum, acEntire, , acSearchAll, ,acCurrent, true
End Sub
Two things I want to change:
1. the search result should display on the top (first column) of the datasheet view, now it is on the bottom.
2. If no matched result, the msgbox show the information “ no match record with this surname”. Now just display the first record in the db.
thank you
I got these code for searching surname in the database. The result is displayed in the data sheet view.
Private Sub GoBtnSurname_Click()
Dim LookforSurname As String
If IsNull(Me!FindSurname) Then
Beep
MsgBox "You Must Enter a Value in the Find Surname Field", [vbOKOnly]
DoCmd.GoToControl ("FindSurname"
Exit Sub
Else
DoCmd.OpenForm ("frmDatasheet"
LookforSurname = Me!FindSurname
DoCmd.GoToControl ("Surname"
DoCmd.RunCommand acCmdSortAscending
DoCmd.FindRecord LookforSurname, , , , , True
End If
While Screen.ActiveForm.Name = "frmDatasheet"
DoEvents
Wend
DoCmd.GoToControl "Case_Num"
DoCmd.RunCommand acCmdSortAscending
DoCmd.FindRecord Common.newCaseNum, acEntire, , acSearchAll, ,acCurrent, true
End Sub
Two things I want to change:
1. the search result should display on the top (first column) of the datasheet view, now it is on the bottom.
2. If no matched result, the msgbox show the information “ no match record with this surname”. Now just display the first record in the db.
thank you