john-86
07-02-2006, 07:00 AM
Hello all,
I've been searching for a solution to this problem for a long time now. I've looked through the forums and through all the help files and the answer still illudes me. I believe I've even posted a message like this a while ago (can be deleted admin. Sorry for the duplication - I have a tight deadline to meet - I'm sure you understand). Can anyone help?
Below is a screengrab the form frmContexts with a tabular subform embedded in it called frmStratigraphy.
http://i57.photobucket.com/albums/g218/johngregson483/frmContexts.jpg
Before I save a record I must check that the context referred to in the subform exists in the recordset (as to not produce orphaned records). Then I must code the reciprocal relationship so that, for example, if I created a link from C3 to C4 - a reciprocal link would have to be created from C4 to C3 with the opposite "relationship" term.
Anyhow, what I'm looking for is a way to select which record is being pointed at since all the control names will be the same. I've wondered whether there was a records collection so that I could do a for each - next loop i.e.
For Each record In recordset
dim contextFound As Boolean
contextFound = False
Do
Do While Not contextRS.EOF
If Forms("frmStratigraphy").txtRelatedContextID.Value = contextRS.Fields("contextID").Value Then
contextFound = True
Exit Do
Else
contextRS.MoveNext
End If
Loop
Loop Until contextRS.EOF
if contextFound = False Then
MsgBox("Context with ID " & forms("frmStratigraphy").txtRelatedContextID.Value & " was not found. There must be a context with this ID already on the database.")
Exit Sub
End If
Next
But there's not records collection. Maybe the above code will indicate better where I'm trying to go with this. If further explanation is needed, just let me know.
Thanks everyone:hi: ,
John
I've been searching for a solution to this problem for a long time now. I've looked through the forums and through all the help files and the answer still illudes me. I believe I've even posted a message like this a while ago (can be deleted admin. Sorry for the duplication - I have a tight deadline to meet - I'm sure you understand). Can anyone help?
Below is a screengrab the form frmContexts with a tabular subform embedded in it called frmStratigraphy.
http://i57.photobucket.com/albums/g218/johngregson483/frmContexts.jpg
Before I save a record I must check that the context referred to in the subform exists in the recordset (as to not produce orphaned records). Then I must code the reciprocal relationship so that, for example, if I created a link from C3 to C4 - a reciprocal link would have to be created from C4 to C3 with the opposite "relationship" term.
Anyhow, what I'm looking for is a way to select which record is being pointed at since all the control names will be the same. I've wondered whether there was a records collection so that I could do a for each - next loop i.e.
For Each record In recordset
dim contextFound As Boolean
contextFound = False
Do
Do While Not contextRS.EOF
If Forms("frmStratigraphy").txtRelatedContextID.Value = contextRS.Fields("contextID").Value Then
contextFound = True
Exit Do
Else
contextRS.MoveNext
End If
Loop
Loop Until contextRS.EOF
if contextFound = False Then
MsgBox("Context with ID " & forms("frmStratigraphy").txtRelatedContextID.Value & " was not found. There must be a context with this ID already on the database.")
Exit Sub
End If
Next
But there's not records collection. Maybe the above code will indicate better where I'm trying to go with this. If further explanation is needed, just let me know.
Thanks everyone:hi: ,
John