Stephd8459
Registered User.
- Local time
- Today, 08:00
- Joined
- Jun 29, 2010
- Messages
- 31
Hi All,
I'm trying to create a command button that opens a second form and when the second form opens have a matching condition.
So basic code would be
The problem is that on the form I want to open 'frmContact' the match would be on 2 fields [FirstName] and [LastName]
So the code I was trying
And this didn't bring a match....
I tried a second option
The problem with the above code based on debug print was that unless I put the open Form command before the strName line strName remained null... If I put the OpenForm before the strName then the matching didn't occur.
I'd appreciate it if anyone has a suggestion. I looked at creating a field FullName in a query and then using that as the match field but I haven't had much luck with that either... I don't have a relationship between the tblContacts which the form is based off and the main form I'm opening it from.
thanks,
Stephanie
I'm trying to create a command button that opens a second form and when the second form opens have a matching condition.
So basic code would be
Code:
Private Sub cmdOpenfrmContacts_Click()
Dim strWhere As String
strWhere = "[Contact] = '" & Me.Contact & "'"
'Open the form
DoCmd.OpenForm "frmContacts", acNormal, , strWhere
End Sub
The problem is that on the form I want to open 'frmContact' the match would be on 2 fields [FirstName] and [LastName]
So the code I was trying
Code:
strWhere = (Forms!frmContacts.FirstName & " " & Forms!frmContacts.LastName) Like "" * "" & Me.Contact & "*"""
And this didn't bring a match....
I tried a second option
Code:
Private Sub cmdOpenfrmContacts_Click()
Dim strWhere As String
Dim strName As String
strName = Forms!frmContacts.FirstName & " " & Forms!frmContacts.LastName
strWhere = strName Like "" * "" & Me.Contact & "*"""
DoCmd.OpenForm "frmContacts", acNormal, , strWhere
The problem with the above code based on debug print was that unless I put the open Form command before the strName line strName remained null... If I put the OpenForm before the strName then the matching didn't occur.
I'd appreciate it if anyone has a suggestion. I looked at creating a field FullName in a query and then using that as the match field but I haven't had much luck with that either... I don't have a relationship between the tblContacts which the form is based off and the main form I'm opening it from.
thanks,
Stephanie