Searching through Database

giant_killa
08-29-2003, 04:03 AM
hey all...

I have the following code that is designed to search through database and display corresponding information on the form.

If (txtCurrentSearch.Text > 1) And (txtCurrentSearch.Text < 99999) Then

For x = 1 To Countdata

If txtCurrentSearch.Text = CurrentSubNum(x) Then

lblCurrentNewSubNum.Caption = "Subscription Number - " & CurrentSubNum(x)
lblCurrentName.Caption = "Name - " & CurrentName(x)
lblCurrentAddress.Caption = "Address - " & CurrentAddress(x)
lblCurrentSex.Caption = "Sex - " & CurrentSex(x)
lblCurrentSubDate.Caption = "Last Subscription Date - " & CurrentSubDate(x)
cmbCurrentSubType.Text = CurrentSubType(x)
cmbCurrentSubAge.Text = CurrentSubAge(x)
End If

Next x

End If

I have only 7 subscription numbers in the database, which range from 10001 - 10007. i want a message box to appear if the number entered does not match the number in the database.
Does anyone know how i can achieve this?

thanks for ya help...

DK

TheDutch IceMan
08-29-2003, 04:11 AM
If rs.RecordCount = 0 Then
Dim intMesg
intMsg = MsgBox ("Sorry, no items found in the database with your argument" & txtCurrentSearch.Text & vbNewLine & "Would you like to enter a new search?"), vbYesNo
If intMsg = vbYes then
frmSearch.show
Else
Exit sub
End If
End If

I don't know exactly how you retrieve your data but in most cases, it functions like it should be.....

zak2zak
08-29-2003, 04:12 AM
Look At The Thread Below...
It should answer u'r questions?
103112

gundavarapu
08-29-2003, 04:27 AM
try this...

rst.Find "FieldName=" & txtSearch.text

If rst.EOF Then
MsgBox "Not in Database"
Else
MsgBox "Exists"
End If

Hope this helps

gundavarapu
08-29-2003, 04:30 AM
intMsg = MsgBox ("Sorry, no items found in the database with your argument" & txtCurrentSearch.Text & vbNewLine & "Would you like to enter a new search?"), vbYesNo


Don't you think it is syntax error :)

TheDutch IceMan
08-29-2003, 05:01 AM
Don't you think it is syntax error :)

hehe...you're right.....early today..... :o

This is better: intMsg = MsgBox("Sorry, no items found in the
database with your argument" & txtCurrentSearch.Text & vbNewLine
& "Would you like to enter a new search?", vbYesNo)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum