Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenForm filter does not work.

Status
Not open for further replies.

weightinwildcat

Programmer
May 11, 2010
84
US
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.
 
Try:

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

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.
 
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.

;-)

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top