×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DoCmd.OpenForm filter does not work.

DoCmd.OpenForm filter does not work.

DoCmd.OpenForm filter does not work.

(OP)
Hi. I am using DoCmd.OpenForm to open an ORDERS form from another form, as follows:

DoCmd.OpenForm ORDERS,,,filter,,

The filter in this case is "OrderNumber = " & Me.OrderNumberBox.Value

Once this happens, I am trying to use Set rs = Me.RecordSet, and then get a count of the number of records using rs.RecordCount; however, the record count always comes up as zero, even when the calling form shows records. Can somebody suggest a fix or a workaround?

Thank you in advance.

RE: DoCmd.OpenForm filter does not work.

Try:

Set rs = Me.RecordSet
If Not(rs.EOF) Then 
    rs.MoveLast
    MsgBox rs.RecordCount
End If
 

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: DoCmd.OpenForm filter does not work.

And the reason for that, is that rs is simply pointing to a recordset object - it has no idea how many records that recordset has until you move it to the last record.
If you used .movefirst instead of .movelast - it would return 1.

winky smile

Def


Give a man a block of code, and he'll solve one problem. Give a man a reason for a block of code, and he'll solve all future problems himself.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close