Continuous Forms Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RAG2007
    New Member
    • Oct 2007
    • 34

    #1

    Continuous Forms Question

    I have a subform that is set in continuous form view. My VBA code fills in specific values in unbound fields on each form in the "On Current" event. The values are dependent on other fields in the form.

    The problem I run into is that, because the records are continuous and therefore all visible, when I am on one record, the unbound fields on all records are given the values of the selected form. When I subsequently select a different record, all unbound fields change to the values associated with the new record.

    Is there anyway to have each record show it's own values, irregardless of which record is selected?

    Here's my code:

    Code:
    Public Sub NameLoader()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim str As String
    
    If IsNull(Me.NameID.Value) = True Then
        Exit Sub
    Else
        str = "SELECT tblName.NameID, tblName.Email, tblName.Phone, tblName.TRRate, tblName.RevRate "
        str = str & "FROM tblName WHERE (((tblName.NameID)=" & Me.NameID.Value & "));"
        Set db = CurrentDb
        Set rst = db.OpenRecordset(str)
        
        Me.Email.Value = rst.Fields("Email").Value
        Me.RevRate.Value = rst.Fields("RevRate").Value
        Me.TRRate.Value = rst.Fields("TRRate").Value
        Me.Phone.Value = rst.Fields("Phone").Value
        
    End If
    End Sub
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can use a query and join them to get the fields or you can use the DLookup() function in the control source.

    Comment

    • RAG2007
      New Member
      • Oct 2007
      • 34

      #3
      DLookup worked great, I'd never used it before. It'll help me in a lot of ways, thanks a lot.

      R

      Originally posted by Rabbit
      You can use a query and join them to get the fields or you can use the DLookup() function in the control source.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Originally posted by RAG2007
        DLookup worked great, I'd never used it before. It'll help me in a lot of ways, thanks a lot.

        R
        Not a problem, good luck.

        Comment

        Working...