It's possible you have some form corruption. First, try changing
Me.txtNR_Program1 to Me!txtNR_Program1, and see if that helps. If it does
help, you probably do have form corruption, and it's probably not completely
fixed. In that case, you should rename the form, paste the controls and code
into a new form object, then delete the old form.
By the way, a policy of using ! instead of . for referencing controls on forms
seems to help reduce the frequency of form corruption problems.
On 26 Apr 2005 09:15:31 -0700,
bradleyp@inspection.gc.ca wrote:
[color=blue]
>Hi all,
>
>Hopefully somebody can help. In Access 2002-SP2, I receive an error
>from the VB Editor if I try to compile the following code (see below).
>The error is as follows:
>
> Compile Error: Method or data member not found
>
>The follow subroutine is highlighted (specifically .txtNR_Program1):
>
>'Assign values to 'Not Reported' column on the report.
>
>Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
> Me.txtNR_Program1.Value = Tests_Status(1, "2005_2424", "", "", "")
> Me.txtNR_Program2.Value = Tests_Status(1, "p2427", "", "", "")
> Me.txtNR_Program3.Value = Tests_Status(1, "p2428a", "p2428b", "", "")
>End Sub
>
>The code for the function, Tests_Status(), is listed below. The
>function is in a separate module.
>
>Public Function Tests_Status(intStatus As Integer, _
> strProgram1 As String, _
> strProgram2 As String, _
> strProgram3 As String, _
> strProgram4 As String) As Integer
>'For Access, define some object variables and make connections.
> Dim cnn As ADODB.Connection
> Set cnn = CurrentProject.Connection
> Dim rst As New ADODB.Recordset
> rst.ActiveConnection = cnn
>'Declare function variable
> Dim intCountTests As Integer
> Dim strStatus_F As String
> Dim strProgram1_F As String
> Dim strProgram2_F As String
> Dim strProgram3_F As String
> Dim strProgram4_F As String
>'Get function inputs and format.
> strStatus_F = "=" & intStatus & ""
> strProgram1_F = "='" & strProgram1 & "')"
> strProgram2_F = "='" & strProgram2 & "')"
> strProgram3_F = "='" & strProgram3 & "')"
> strProgram4_F = "='" & strProgram4 & "');"
>'Build a SQL string
> rst.Open "SELECT Count(tblTests.[LSTS_Reported]) AS [Count_Tests] "
>& _
> "FROM tblSamples INNER JOIN tblTests " & _
> "ON tblSamples.LSTS_Number = tblTests.LSTS_Number " & _
> "WHERE (tblTests.LSTS_Reported " & strStatus_F & _
> "AND tblSamples.Program_Number " & strProgram1_F & _
> "OR (tblTests.LSTS_Reported " & strStatus_F & _
> "AND tblSamples.Program_Number " & strProgram2_F & _
> "OR (tblTests.LSTS_Reported " & strStatus_F & _
> "AND tblSamples.Program_Number " & strProgram3_F & _
> "OR (tblTests.LSTS_Reported " & strStatus_F & _
> "AND tblSamples.Program_Number " & strProgram4_F
>'Obtain records from the recordset called "rst"
> intCountTests = rst("Count_Tests")
>'Clear the object variables
> rst.Close
> cnn.Close
>'Return value
> Tests_Status = intCountTests
>End Function
>
>Why am I getting this error? Note that the report works fine in
>operation. I only get this error when I try to compile the code. Thanks
>in advanced.
>
>Peter[/color]