[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 879
  • Last Modified:

How to refer to a specific field record in a subform?


I have inserted a continuous subform in a form.
The subform is a query and is used to view all records from the query and also enter information through certain fields in the query back down to the related table.

The problem is when I try to disable certain subform field records depending on corresponding subform field records, the whole field gets disabled.
In the following piece of code when I update a record in the 'Ignored' field and its answer is 'Yes', then I want to disable the corresponding record in the 'Reference' field.
The code I used behind the subform was

Private Sub .......
    If Ignored.Value = "Yes" Then
       Reference.Enabled = False
        Reference.Enabled = True
    End If
End Sub

This code disabled the whole 'Reference' field instead of just a specific record in the field.

I think the code I am trying to run would look something like the following;

Private Sub .......
    Dim RecNum As Integer
    RecNum = Me.CurrentRecord
    If Ignored.Value(RecNum) = "Yes" Then
       Reference.Enabled(RecNum) = False
        Reference.Enabled(RecNum) = True
    End If
End Sub

I would appreciate your help,
Alan OBrien
Alan OBrien
  • 2
1 Solution
THe control is enabled ( for all records) or disabled (for all records).

You don't say where you have your existing code: you might need it to run in a couple of different cases:

1 - when changing value of Ignored
2 - when moving to a new record

Alan OBrienSystems AdministratorAuthor Commented:
I'm not sure if you fully understood what I meant by the above question.

Basically I want to be able to refer to a specific field of a record  for example

on a dataset subform i select(place the cursor in) column 3 row 4. i.e the 4th record of a field
what is the correct syntax in VBA to say the value of the selected field
 for  example i thought it would be      


but this does not compile.

On a continuous form, I don't know of any way to specify the row.   There is one 'active' row and when you refer to the fieldnames, you always are referring to the active row.  

If you move your cursor to the 4th row, and any VBA Code runs, it will always run against the 4th row (until you move your cursor to another row).  By putting your cursor there, you've made that row the 'active' row.   In code on your subform, you can say me.fieldname.value.

Hope that helps.
Sorry, I re-read my comment and this is unclear:
"On a continuous form, I don't know of any way to specify the row."
Should read:
"On a continuous form, I don't know of any way to specify the row in VBA Code."

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now