By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Find Record Command

P: 2
hi...im trying to design the "find record" command whereby the user enters an ID Number and than clicks ok and the database does a search for that particular ID...the wizard command uses find and replace but rather i would just like to have "find record"..ive read recent forums on the same question and decided to try a script that was posted in one of the forums...here is the script
Dim strFindID As String


strFindID = InputBox("Enter the ODSTL/Licensce_No:")


If IsNumeric(strFindID) Then
With Me.RecordsetClone
.FindFirst "[ODSTL/Licensce_No]=" & strFindID
If .NoMatch Then
MsgBox "Sorry, couldn't find that ID#."
Else
Me.Bookmark = .Bookmark
End If
End With
Else
MsgBox "Please enter a valid ID#!"
End If

I've added this script to the "find record" command button but it still doesnt work..the command button is designed to be in a form....please help.....
Jul 24 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,638
hi...im trying to design the "find record" command whereby the user enters an ID Number and than clicks ok and the database does a search for that particular ID...the wizard command uses find and replace but rather i would just like to have "find record"..ive read recent forums on the same question and decided to try a script that was posted in one of the forums...here is the script
Dim strFindID As String


strFindID = InputBox("Enter the ODSTL/Licensce_No:")


If IsNumeric(strFindID) Then
With Me.RecordsetClone
.FindFirst "[ODSTL/Licensce_No]=" & strFindID
If .NoMatch Then
MsgBox "Sorry, couldn't find that ID#."
Else
Me.Bookmark = .Bookmark
End If
End With
Else
MsgBox "Please enter a valid ID#!"
End If

I've added this script to the "find record" command button but it still doesnt work..the command button is designed to be in a form....please help.....
You're dimensioning strFindID as a String but checking to see if it is Numeric - is ODSTL/Licensce_No a Number or String? If it is a String in a Numeric Format, then the Syntax is wrong.
Jul 24 '07 #2

P: 2
You're dimensioning strFindID as a String but checking to see if it is Numeric - is ODSTL/Licensce_No a Number or String? If it is a String in a Numeric Format, then the Syntax is wrong.
ODSTL is a number....Each cutomer has a unique ODSTL number...It is labelled as such - Licensce_No - ODSTL 002/01..The Licensce_No is an attribute in the tale. Which syntax do i need to change??
Jul 24 '07 #3

ADezii
Expert 5K+
P: 8,638
ODSTL is a number....Each cutomer has a unique ODSTL number...It is labelled as such - Licensce_No - ODSTL 002/01..The Licensce_No is an attribute in the tale. Which syntax do i need to change??
Assuming ODSTL/Licensce_No is the name of the Field in the underlying RecordSource of your Form, and you have already stated that it is Unique, then:
Expand|Select|Wrap|Line Numbers
  1. Dim varFindID As Variant
  2.  
  3. varFindID = InputBox("Enter the ODSTL/Licensce_No:")
  4.  
  5. If IsNumeric(varFindID) Then
  6.   With Me.RecordsetClone
  7.     '.FindFirst "[ODSTL/Licensce_No]=" & varFindID
  8.     If .NoMatch Then
  9.       MsgBox "Sorry, couldn't find that ID#."
  10.     Else
  11.       Me.Bookmark = .Bookmark
  12.     End If
  13.   End With
  14. ElseIf Len(CStr(varFindID)) = 0 Then
  15.   'User pressed Cancel or OK with no entry in Text Box, just let go
  16. Else     'if it gets to this point, something was entered but it wasn't a Number
  17.   MsgBox "Please enter a valid ID#!"
  18. End If
Jul 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.