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

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

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

All,

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
    Else
        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
    Else
        Reference.Enabled(RecNum) = True
    End If
End Sub

I would appreciate your help,
Thanks,
aobrien32
0
Alan OBrien
Asked:
Alan OBrien
  • 2
1 Solution
 
aflockhartCommented:
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


0
 
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      

fieldname(4).value

but this does not compile.



0
 
BrentTempleCommented:
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.
-Brent
0
 
BrentTempleCommented:
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."
0

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