Results 1 to 9 of 9
  1. #1
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58

    RecordSet Clone Problem with code

    I am currently getting an error with the following code. The error is "mothod or data member not found" and all fields are defined correctly as far as i know. Any ideas on what I am doing wrong? Thanks



    Code:
    Private Sub InvestorLoanNumber_BeforeUpdate(Cancel As Integer)
    Dim SID As String
    Dim stLinkCriteria As String
    Dim rsc As DAO.Recordset
    Dim SID1 As String
    Dim stLinkCriteria1 As String
    Dim rsc1 As DAO.Recordset
    Set rsc = Me.RecordsetClone
    Set rsc1 = Me.RecordsetClone
    If Not IsNull(Me.InvestorLoanNumber) And Not IsNull(Me.HLoanNumber) Then
    SID = Me.Investor_Loan_Number.Value
    SID1 = Me.H_Loan_Number.Value
    stLinkCriteria = "[InvestorLoanNumber]=" & "'" & SID & "'"
    stLinkCriteria1 = "[HLoanNumber]=" & "'" & SID1 & "'"
    
        If DCount("InvestorLoanNumber", "Repurchase", stLinkCriteria) > 0 And DCount("HLoanNumber", "Repurchase", stLinkCriteria1) > 0 Then
        
            Me.Undo
            MsgBox "H Loan Number " _
            & SID1 & " and Investor Loan Number " _
            & SID & " has already been entered." _
            & vbCr & vbCr & "You will now been taken to the record.", vbInformation _
            , "Duplicate Information"
        
     
            rsc.FindFirst stLinkCriteria
            Me.Bookmark = rsc.Bookmark
        
        
            rsc1.FindFirst stLinkCriteria1
            Me.Bookmark = rsc1.Bookmark
        End If
    Set rsc = Nothing
    Set rsc1 = Nothing
    End If
    On Error GoTo Err_H
    Err_H:
    Exit Sub
    End Sub

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    line num?....

  3. #3
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58
    Line 11 "SID = Me.Investor_Loan_Number.Value"

    the Investor_Loan_Number is in another form. Thanks

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's a good link on the syntax for using the Forms collection to reference a control on another form.
    http://access.mvps.org/access/forms/frm0031.htm

  5. #5
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58
    so if i am trying to look within a table called Investor_request, would it be me!investor_request.investor_loan_number.value.

    I think I tried this but it did not work. Any ideas? Thanks

  6. #6
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    see RuralGuy's linkage.

  7. #7
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58
    I did but I am not understanding it since I am new to access and programming. I am trying to reference table: Investor_Request and look within the field: Investor_Loan_Number for that value.

    Thanks

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can use a Domain function to look inside a table if you want (DLookup, DCount, etc). The link I provided was the syntax for using the Forms collection to look at a control in another open form.

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Info on how to refer to controls on a form using the "ME" property. (from A2K3 Help)
    ---------------------------------------------------

    Me Property (of forms & reports)



    You can use the Me property in Visual Basic to refer to a form, report, (or to the form or report associated with a subform or subreport), or class module where Visual Basic code is currently running.

    Setting

    The Me property is available only by using Visual Basic and is read-only in all views.

    Remarks

    The Me property contains an object reference to the current form or report and is faster than a fully qualified object reference.
    For example, the following two code fragments refer to the value of the LastName control for the current record on the Employees form:


    strLastName = Forms!Employees.LastName
    strLastName = Me!LastName

    In most cases, the form or report referred to by the Me property is the same form or report referred to by the ActiveForm or ActiveReport properties of the Screen object. However, these properties refer to the form or report with the forcus, whereas the Me property always refers to the form or report in which code is running.

    -------------------------------------------------------

    So if the control that has the data is on a different form, you cannot refer to it using the "Me" keyword. AND the form has to be open. The syntax to refer to a control on a different form is

    Code:
    Forms!FormName.ControlName
    (Note: you do not have to type ".Value" because the value property is the default property.)



    --------------------------------------------------------------------------------------------
    I also noticed some errors in the code.

    You have these three lines:
    Code:
    If Not IsNull(Me.InvestorLoanNumber) And Not IsNull(Me.HLoanNumber) Then 
    
    SID = Me.Investor_Loan_Number.Value 
    SID1 = Me.H_Loan_Number.Value
    Why does (in red/blue) does one reference have underscores and the other one doesn't??


    I modified your code a little ....


    Code:
    Private Sub InvestorLoanNumber_BeforeUpdate(Cancel As Integer)
       On Error GoTo Err_H
    
       Dim rsc As DAO.Recordset
       Dim rsc1 As DAO.Recordset
       Dim SID As String
       Dim SID1 As String
       Dim stLinkCriteria As String
       Dim stLinkCriteria1 As String
    
       Set rsc = Me.RecordsetClone
       Set rsc1 = Me.RecordsetClone
    
    
      '   If Not IsNull(Me.InvestorLoanNumber) And Not IsNull(Me.HLoanNumber) Then
      '   SID = Me.Investor_Loan_Number
      '   SID1 = Me.H_Loan_Number
    
    'change form1 to your form name
       SID = Forms!form1.Investor_Loan_Number
       SID1 = Forms!form1.H_Loan_Number
    
       If Not IsNull(SID) And Not IsNull(SID1) Then
    
          stLinkCriteria = "[InvestorLoanNumber] = '" & SID & "'"
          stLinkCriteria1 = "[HLoanNumber] = '" & SID1 & "'"
    
          If DCount("InvestorLoanNumber", "Repurchase", stLinkCriteria) > 0 And DCount("HLoanNumber", "Repurchase", stLinkCriteria1) > 0 Then
    
             Me.Undo
             MsgBox "H Loan Number " & SID1 _
                    & " and Investor Loan Number " & SID _
                    & " has already been entered." _
                    & vbNewLine & vbNewLine & "You will now been taken to the record.", vbInformation _
                                                                                          , "Duplicate Information"
    
    
             rsc.FindFirst stLinkCriteria
             Me.Bookmark = rsc.Bookmark
    
             ' There is only ONE "Me.Bookmark"
             ' Which record do you want to go to??
             '         rsc1.FindFirst stLinkCriteria1
             '         Me.Bookmark = rsc1.Bookmark
    
          End If
          Set rsc = Nothing
          Set rsc1 = Nothing
       End If
    
    Err_Exit:
       Exit Sub
    
    Err_H:
       MsgBox Err.Description, vbInformation
    
    End Sub



Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2023, 08:41 AM
  2. multiple combo boxes recordset clone
    By trigirl67 in forum Forms
    Replies: 1
    Last Post: 01-30-2012, 02:32 PM
  3. Recordset problem(s)
    By bbrazeau in forum Programming
    Replies: 14
    Last Post: 10-19-2011, 12:41 PM
  4. Recordset cycle problem
    By free_style in forum Programming
    Replies: 3
    Last Post: 08-25-2011, 02:44 PM
  5. Recordset Findfirst Problem
    By ColPat in forum Programming
    Replies: 6
    Last Post: 07-22-2010, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums