Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Drop Down Box

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have this code on a drop down box in a form. It works well if the numbers are greater or equal to 100. If I select for example a number 28 it brings up 128. Please take a look and let me know where I have gone wrong. Thanks for your assistance.

Dim rs As DAO.Recordset, okay1 As Boolean
'If IsNull(Me.txtSrch1) Then
'MsgBox "You must have a string "

'Exit Sub
'End If

Set rs = Me.RecordsetClone

rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF

If IsNull(Me.txtSrch1) Then
okay1 = True

Else
okay1 = (InStr(rs![PickupID], Me.txtSrch1) > 0)

End If

If okay1 Then
Me.Bookmark = rs.Bookmark
Exit Do
End If
rs.MoveNext

Loop
rs.Close
Set rs = Nothing
 
Why not simply this ?
Code:
Set rs = Me.RecordsetClone
If Not IsNull(Me!txtSrch1) Then
  rs.FindFirst "PickupID=" & Me!txtSrch1
  If Not rs.NotFound Then
    Me.Bookmark = rs.Bookmark
  End If
End If
Set rs = Nothing

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top