Firstly, thanks for time to look at this. I'm painfully aware of my VBA noobness right now so its much appreciated.
Now for some context. I have a main form with multiple pages. The first page has search functionality, the search results are displayed in a subform.
The functionality I am trying to implement is when a record in the subform (search results) is d/clicked:
A) Current record on the main form will be changed to be the record selected in the subform
B) The main form focus will switch to a different page of the main form (eg. mainform search page > mainform detail page)
Pretty basic huh?
Well I'm having a nightmare trying to figure out A).
Here's what I've got so far:
Any ideas wise ones?
Now for some context. I have a main form with multiple pages. The first page has search functionality, the search results are displayed in a subform.
The functionality I am trying to implement is when a record in the subform (search results) is d/clicked:
A) Current record on the main form will be changed to be the record selected in the subform
B) The main form focus will switch to a different page of the main form (eg. mainform search page > mainform detail page)
Pretty basic huh?
Well I'm having a nightmare trying to figure out A).
Here's what I've got so far:
Code:
'Main-form has a field called contactID
'Sub-form has a field called contactID
'Need to update main-form contactID = sub-form contactID
Function OpenRecordForEditing()
On Error GoTo ProcError
Dim varRecord As Variant
If Not IsNull([ContactID]) Then
'SWITCH TO THE DETAIL PAGE
Forms!Contacts.Controls!TabControl_Contacts.Value = 1
Forms!Contacts!FirstName.SetFocus
'FIND THE RECORD
'DoCmd.FindRecord ContactID, acAnywhere, , acSearchAll, , , True
'DoCmd.FindRecord Forms!ContactsSubform.ContactID, acAnywhere, , acSearchAll, , , True
End If
ExitProc:
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in OpenRecordForEditing event procedure..."
Resume ExitProc
End Function
Any ideas wise ones?