Do Until Question

mrssevans

Registered User.
Local time
Today, 03:53
Joined
Nov 15, 2001
Messages
190
I am needing to search through a table for a specific number matching a number on a form and then enter that number into a subform. I have been trying to use the EOF or Do Until, but don't know if I am on the right track. Can anyone send me in the right direction?
 
U can create a query with criteria pointing to a form's textbox. Click on build expression editor en navigate to the forms textbox (probably)

HTH

M.
 
For the subform u can probably use Link child/master property and enter the desired field.
 
The above may work, or DLookUp may be the answer to your problem. All depends on what you are trying to do...
 
Both suggestions are very much appreciated. I will give them a try and see which one works best. Thanks for your help!!
 
DAO Example

Code:
Do While Not rst.EOF And Not rst.BOF 

    rst.FindNext ("[myNumber] = " & myNumber)
    
    If rst.NoMatch Then
        MsgBox "No Match"
    Else
[COLOR=green]        'replace myNumber with appropriate field 
        'if not using myNumber to set value in subform[/color]
        NumberFound = rst.Fields("myNumber")
[COLOR=green]        'Add code to set appropriate control to NumberFound[/color]     
    End If
    
Loop
Should give you a starting point. Don't forget to
- Dim & Set your Database, Recordset
- set your DAO references

Edit: I think you won't even need the loop.

Edit # 2:What exactly are you trying to accomplish?
Take number in Main form, look for it in table used by SubForn and edit the number in the subform (showing only one or mot than one records at a time?) or enter that in a new in the subform?

An explanation on what and why you are trying to do might help us here to understand what you need to accomplish as opposed to what you want to accomplish (I've learned that they aren't always the same thing!).

Hope this helps!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom