Need Help with FIND & OPTION BTN 
Author Message
 Need Help with FIND & OPTION BTN

Here is my question.... I currently have a form that has a OPTION BOX with 6
possible selections. I would like to know, how can I set the find method to
search for a record using a specific criteria... For example....

If the user selects OPTION Button #1 the find method, will find the record
using the customers account#, if Option Button#2 is selected, it will search
for records using PO number, and so on... currently I'm using an option box
with 6 option buttons, a textbox for search criteria & the search button,
that I'm currently trying to code...  part of the code look like this:

' **********************
' * table name---> mastertable
' * fields to search for --> StrAccountNum, StrAccountNum, strLastName,
StrPO, etc (all are str)
' **********************
' * inputs -->> TxtCriteria (textbox that the user will use to type criteria
' * fraSeacrhSelection ->> option box name (from 1 to 6 options)
' **********************

Private Sub Command139_Click()

On Error GoTo Err_Command139_Click
Dim dbs As Database, rst As Recordset
Dim strWhere As String
Dim strecord As String
Dim varBookmark As Variant

Select Case fraSeacrhSelection ' option btn name <<<<----
Case 1
  strWhere = "[straccountnum]>='" & Me!TxtCriteria & "'"
' ******** CASE SHOULD BE FROM  1 TO 6, ONLY USED 1 CASE FOR TESTING
PURPOSES

 End Select
 Set dbs = CurrentDb         ' Define search criteria.
 Set rst = dbs.OpenRecordset("mastertable", dbOpenDynaset)
 rst.FindFirst strWhere
 varBookmark = rst.Bookmark

 If rst.NoMatch Then
        MsgBox "No record(s) found."
    Else
        ' Find other matching records.
        Do Until rst.NoMatch
' ****** I know it's working; it displays this page
            Me.GoToPage 2
' ***** need to know how to display record just found *******
            rst.FindNext strWhere
        Loop
    End If
    rst.Close
    Set dbs = Nothing

Exit_Command139_Click:
 Exit Sub
Err_Command139_Click:
 MsgBox Err.Number & " " & Err.Description, vbInformation, "Error"
 Resume Exit_Command139_Click

End Sub

Can someone tell me what I'm doing wrong???

Thanks in advance
Alex



Thu, 13 Mar 2003 03:00:00 GMT  
 Need Help with FIND & OPTION BTN
Your approach is basically sound.
What do you want to do with this record once you've found it?

- Turtle

PS That's a lot of groups you're cross-posting to.  One or two is generally
sufficient.

Here is my question.... I currently have a form that has a OPTION BOX with 6
possible selections. I would like to know, how can I set the find method to
search for a record using a specific criteria... For example....

If the user selects OPTION Button #1 the find method, will find the record
using the customers account#, if Option Button#2 is selected, it will search
for records using PO number, and so on... currently I'm using an option box
with 6 option buttons, a textbox for search criteria & the search button,
that I'm currently trying to code...  part of the code look like this:

' **********************
' * table name---> mastertable
' * fields to search for --> StrAccountNum, StrAccountNum, strLastName,
StrPO, etc (all are str)
' **********************
' * inputs -->> TxtCriteria (textbox that the user will use to type criteria
' * fraSeacrhSelection ->> option box name (from 1 to 6 options)
' **********************

Private Sub Command139_Click()

On Error GoTo Err_Command139_Click
Dim dbs As Database, rst As Recordset
Dim strWhere As String
Dim strecord As String
Dim varBookmark As Variant

Select Case fraSeacrhSelection ' option btn name <<<<----
Case 1
  strWhere = "[straccountnum]>='" & Me!TxtCriteria & "'"
' ******** CASE SHOULD BE FROM  1 TO 6, ONLY USED 1 CASE FOR TESTING
PURPOSES

End Select
Set dbs = CurrentDb         ' Define search criteria.
Set rst = dbs.OpenRecordset("mastertable", dbOpenDynaset)
rst.FindFirst strWhere
varBookmark = rst.Bookmark

If rst.NoMatch Then
        MsgBox "No record(s) found."
    Else
        ' Find other matching records.
        Do Until rst.NoMatch
' ****** I know it's working; it displays this page
            Me.GoToPage 2
' ***** need to know how to display record just found *******
            rst.FindNext strWhere
        Loop
    End If
    rst.Close
    Set dbs = Nothing

Exit_Command139_Click:
Exit Sub
Err_Command139_Click:
MsgBox Err.Number & " " & Err.Description, vbInformation, "Error"
Resume Exit_Command139_Click

End Sub

Can someone tell me what I'm doing wrong???

Thanks in advance
Alex



Thu, 13 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help - Cannot find the options Trigger and Stored Proc in MS Access

2. reset Toggle btn in Option Grp when, Next Record

3. HTML Help with P&D: Htmhelp not found, MyProject.chi not found

4. HELP: Making a find option

5. Need Help Editing a Document Based on Dialog Box Options

6. Menu help needed for options

7. Need help with option button event

8. Need Help Formatting Options Dialog: puttig elements on 2nd - nth tabs

9. Help needed graphing stocks/options

10. Help needed graphing stocks/options

11. Help needed graphing stocks/options

12. Need to find Video & Audio cards

 

 
Powered by phpBB® Forum Software