how to put messagebox "not found"

hello please help me on this how to put the messagebox if the precinct number is not found,,.because if i put on the else after the grd.Rows = grd.Rows + 1 he will only display one person having this precint number all i want that all person having the precint number will be display.here are the list....D-314 is the precinct number...hoping for your positive responds.thanks in advance.... "D-314","England","0001","michael","lambert","s","london",26 "C-245","America","0002","deca","fischer","s","california",29 "D-314","China","0003","Miller","anna","s","new zealand",21 "C-245","Belgium","0004","fullinto","fanley","s","iceland",22 "D-314","Norway","0005","jerusalem","emmanuel","s","Nazareth",25 "D-314","Singapore","0006","hhhhh","nave`","d","Africa",29 "C-245","Thailand","0007","ggg","yyyyyy","s","uptown",30 "E-344","Brunei","0008","llllll","l;k;lk;l","d","new town",29 "D-314","United Kingdom","0009","jlkjlkjl","qlkjlkjlk","s","lkjlkj",26 "C-245","Africa","0010","ffff","ff","f","ff",34 "C-245","Laos","0011","fdfdfdf","fff","s","f",67 "A-342","Harvard","0012","fff","f","f","f",23 "D-314","Korea","0013","rrrrrr","ssss","k","kkk",22 ////here is my code Private Sub cmdExit_Click() End End Sub Public Sub header() grd.Clear grd.Rows = 2 grd.Cols = 4 grd.ColWidth(1) = 2000 grd.ColWidth(2) = 1500 With grd .TextMatrix(0, 0) = "Voters idno" .TextMatrix(0, 1) = "Voters name" .TextMatrix(0, 2) = "address" .TextMatrix(0, 3) = "age" End With End Sub Private Sub Form_Load() header End Sub Private Sub txtpno_KeyDown(KeyCode As Integer, Shift As Integer) gFnum = FreeFile If KeyCode = 13 Then m_pno = Trim(UCase(txtpno.Text)) txtpno.SetFocus Open "voters.dat" For Input As #gFnum Do Until EOF(gFnum) Input #gFnum, pn, adress, vidno, last, first, middle, address, age If m_pno = pn Then With grd .TextMatrix(grd.Rows - 1, 0) = vidno .TextMatrix(grd.Rows - 1, 1) = last + "," + first + "" + middle .TextMatrix(grd.Rows - 1, 2) = address .TextMatrix(grd.Rows - 1, 3) = age End With grd.Rows = grd.Rows + 1 End If Loop Close #gFnum End If End Sub
Submitted bycidfreyon Tue, 01/19/2010 - 00:05

Change some codes because this is from my Payroll System. I use Combo Box and Text. Combo Box is for the category like number or name or the country and Text is for "ex: if you choose number from the category this is where you input it, or if name of the country this is where you input it" Private Sub Command5_Click() Dim find As String find = Text9.Text If Combo1.Text = "EMPOYEE NO." Then If Text9.Text = "" Then Exit Sub End If Adodc1.Refresh Do Until Adodc1.Recordset.EOF If find = Text1.Text Then MsgBox "Employee number found.", 0 + 48, "Message" Exit Sub Else Adodc1.Recordset.MoveNext End If Loop MsgBox "Employee number not found.", 0 + 48, "Message" Text9.SetFocus ElseIf Combo1.Text = "NAME" Then If Text9.Text = "" Then Exit Sub End If Adodc1.Recordset.Sort = "name1" Do Until Adodc1.Recordset.EOF If find = Text2.Text Then MsgBox "Employee name found.", 0 + 48, "Message" Exit Sub Else Adodc1.Recordset.MoveNext End If Loop MsgBox "Employee name not found.", 0 + 48, "Message" Text9.SetFocus Else MsgBox "Select at the category.", 0 + 48, "Message" Combo1.SetFocus End If End Sub

Add new comment