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:
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
Comment