Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Db 'Can't Find ' Existing Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JamesJ - 24 Nov 2005 00:57 GMT
Hi. I'm using the following code on the OnCurrent of the form
to return the number of rows being returned in my continuous form:

In the General section of the module:

Dim frm As Form
------------------------------------------------------
Public Function RecCount()

   Dim intCount As Integer
   Set frm = Screen.ActiveForm

       If frm.Recordset.RecordCount = 0 Then

           frm!lblCount.Caption = "0 Item(s)"

       Else

           intCount = frm.Recordset.RecordCount
           frm!lblCount.Caption = intCount & " Item(s)"

       End If

End Function

The code works fine as a form function but not in a module.
I get the following Error:

Run-time error '2465':

MyDb can't find the field lblCount referred to in your expression.

The field is a label and is named lblCount.

Any help will be appreciated.

Thanks and Happy Thanksgiving!
James
Terry - 24 Nov 2005 02:24 GMT
Maybe

Dim frm as form

> Hi. I'm using the following code on the OnCurrent of the form
> to return the number of rows being returned in my continuous form:
[quoted text clipped - 34 lines]
> Thanks and Happy Thanksgiving!
> James
Terry - 24 Nov 2005 02:33 GMT
Hit the wrong key

dim frm as form goes within function

> Maybe
>
[quoted text clipped - 38 lines]
>> Thanks and Happy Thanksgiving!
>> James
JamesJ - 24 Nov 2005 02:40 GMT
Same results

> Hit the wrong key
>
[quoted text clipped - 42 lines]
>>> Thanks and Happy Thanksgiving!
>>> James
tina - 24 Nov 2005 04:41 GMT
i couldn't get anything to work using Screen.ActiveForm. but assuming that
every form that calls the function contains a label object named lblCount,
the following should work in a public module, as

Public Function RecCount()

   On Error Resume Next

   Dim intCount As Integer

   With CodeContextObject
       .RecordsetClone.MoveLast
       intCount = .RecordsetClone.RecordCount
       If intCount = 1 Then
           !lblCount.Caption = "1 Item"
       Else
           !lblCount.Caption = intCount & " Items"
       End If
   End With

End Function

hth

> Same results
>
[quoted text clipped - 44 lines]
> >>> Thanks and Happy Thanksgiving!
> >>> James
JamesJ - 24 Nov 2005 13:31 GMT
I altered the code and I'm not sure why this works but..
I needed to check for no records so when the continuous form
displays only the new record the lblCount caption displays
0 Item(s). I was banging my head trying to check for no
records and I apparently don't need to.
All is fine now. Thanks

On Error Resume Next

   Dim intCount As Integer

   With CodeContextObject
       intCount = .RecordsetClone.RecordCount
       !lblCount.Caption = intCount & " Items"
   End With

Thanks again,
James

>i couldn't get anything to work using Screen.ActiveForm. but assuming that
> every form that calls the function contains a label object named lblCount,
[quoted text clipped - 68 lines]
>> >>> Thanks and Happy Thanksgiving!
>> >>> James
tina - 24 Nov 2005 23:58 GMT
you're welcome  :)

> I altered the code and I'm not sure why this works but..
> I needed to check for no records so when the continuous form
[quoted text clipped - 87 lines]
> >> >>> Thanks and Happy Thanksgiving!
> >> >>> James
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.