Alan OBrien
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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."
"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."
ASKER
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.