Hello,
I am trying to refer to fields on a given form from the form query's recordset, essentially from the following commands:
My question is how do I refer to a field in the form's record set (not an individual control on the form)? If I use frm![LineTag].Value, it works fine, but frm.Fields(tagN ame).Value does not. Conversely, rs.Fields(tagNa me) does work fine. (note: tagName="LineTa g")
Please let me know how I can refer to a form's recordset field.
Thanks!
...
For more info and as to why I need it, here is a large chunk of the function I use to call the segments mentioned above:
I am trying to refer to fields on a given form from the form query's recordset, essentially from the following commands:
Code:
Dim frm As Form 'Refers to the current form
Dim tagName As String 'Refers to the field in the form's recordset (not a control on the form)
...
frm.Fields(tagName).Value 'This gives Error 2465
Please let me know how I can refer to a form's recordset field.
Thanks!
...
For more info and as to why I need it, here is a large chunk of the function I use to call the segments mentioned above:
Code:
Function duplicateRecord(ByRef frm As Form, tableName As String, uniqueCtl As TextBox, tagName As String, ByRef avarExceptionList() As String) As Long Dim rsExist As Recordset
Dim keyName As String, keyValue As Long
Dim tempRecord As Long
Dim fld As Field
On Error GoTo Err_duplicateRecord
Set rsExist = CurrentDb.OpenRecordset(tableName)
keyName = uniqueCtl.ControlSource
If uniqueCtl.Value > 1 Then
keyValue = uniqueCtl.Value
If frm.NewRecord Then
Call MsgBox("New records cannot be duplicated, please save this record first then try again.", vbExclamation, "Nonexistant Record")
duplicateRecord = -1
Exit Function
ElseIf frm.Dirty Then
If MsgBox("Save changes?", vbYesNo, "Unsaved Changes Detected") = vbYes Then
MsgBox frm.Fields("LineTag")
If isSaveable(tableName, tagName, frm.Fields(tagName).Value, keyName, keyValue) Then 'This gives Error 2465
Call saveRecord(frm, keyValue)
Else
Exit Function
End If
Else
Exit Function
End If
End If
...
End Function
Comment