Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset.clone challenge - find record in other subform

Status
Not open for further replies.

diwin

Technical User
Nov 29, 2002
218
CA
access 2002.
Recordset.clone challenge

I have 2 sibling continuous subforms on the main form that contain Contacts from 2 Organizations. They are going to be merged to 1 Organization, so one of the Main contacts will be demoted.
In an unbound combo box that is in both subforms, the user has to update one of the Contact ranks from Main to something lesser, because there can be only one Main Contact. The one that remains Main will be the Main Contact in the other subform.

What I want to do is switch the focus, when the user attempts to select the Main option in the dropdown in one subform, to the other Main Contact's dropdown in the other subform, accompanied by a validation message like "Demote existing Main before designating another Main."

I have tried with .setfocus and recordset.clone, but I can't get it to work right.

'User tries to create new Main Contact when
'one already exists in the other subform.

Private Sub RcboRelation_AfterUpdate()
If sMainExists = 1 And RcboRelation = 1 Then 'And iID <> RID Then
MsgBox "You can only have one " & Chr(34) & "Main" & Chr(34) & " Contact." & vbCrLf & _
" Change the existing " & Chr(34) & "Main" & Chr(34) & " Contact to something else" & vbCrLf & _
" before making this the " & Chr(34) & "Main" & Chr(34) & " Contact.", , "Only One " & Chr(34) & "Main" & Chr(34) & " Contact Allowed!"
Me.RcboRelation = DLookup("contact_FrelationIDRestore", "tblTempEditContactsChangeRelations", "contactID = " & Me.RID)
Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If rst.NoMatch Then
Set rst = Nothing
Me.Parent!frmEditContactsChangeRelationsSub.SetFocus
Forms!frmEditContactsChangeRelations!frmEditContactsChangeRelationsSub.Form!RcboRelation.SetFocus
Exit Sub
Else
Me.Bookmark = rst.Bookmark
Set rst = Nothing
End If
End If
End Sub

'Dropdown in other subform to receive focus for record
that has existing Main Contact.

Private Sub RcboRelation_GotFocus()
Me.RcboRelation.Dropdown
If Me.Parent.OpenArgs = "Merge" And Me.RcboRelation = 1 Then 'And x = y
strCriteria = "[contact_FrelationIDRestore] = 1 AND contact_FparentIDRestoreBlind = " & Me.Parent!RParentID
Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If rst.NoMatch Then
MsgBox "Daniel... No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
Me.RcboRelation.Dropdown
End If
Set rst = Nothing
End If
End Sub


Daniel Dillon
o (<--- brain shown at actual size.)
 
Problem solved. I got it!
If you want to know just post a reply.

Daniel Dillon
o (<--- brain shown at actual size.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top