Record Selector

G

Guest

Hi there,
I am need of some coding help.

In the following code I am trying to look through a predetermined table, and
then look for A certain record which matches the specific criteria.
------
CloseCat = "Closed"
strType = "1"

rsMyRS.MoveFirst
Do Until rsMyRS.EOF

If rsMyRS.Fields!DIR = strDir And rsMyRS.Fields!CAT = strType And
rsMyRS.Fields!CLOSE = CloseCat Then '(3)
cmdClose.Enabled = False
rsMyRS.EOF
Else
cmdClose.Enabled = True
rsMyRS.MoveNext
End If

Loop

The problem I have is that I cant stop the loop when it reaches the record
I want. There cannot be more than one of the "wanted" records.
If the data matches the DIR #, the Catagory, and the Close Catagory then I
want it to disable the command button and stop running the loop.
Since there is only 1 record which matches this criteria and is not in most
cases the last record the loop finishes with the "Else" statement, enabling
the command button..even though the record may exist.

Thanks in advance.
-State
 
B

Brendan Reynolds

If I understand correctly, I think what you need it to replace this ...

cmdClose.Enabled = False
rsMyRS.EOF
Else

.... with this ...

cmdClose.Enabled = False
Exit Do
Else
 
G

Guest

I gave it a shot, but it seems to still run through the rest of the loop.
-----
Do Until rsMyRS.EOF

If rsMyRS.Fields!DIR = strDir And rsMyRS.Fields!CAT = strType And
rsMyRS.Fields!CLOSE = CloseCat Then '(3)
'cmdClose.SetFocus
cmdClose.Enabled = False
Exit Do
Else
cmdClose.Enabled = True
rsMyRS.MoveNext
End If

Loop


Not sure what other options are available here.

Thanks again.
-State
 
G

Guest

It worked.
I had: cmdClose.Enabled = True
in another procedure.

Thanks for the help.
-State
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top