 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 4th, 2010, 03:27 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
|
|
Access: How can I pass 2 values on the Forms
Hi everyone, please help me.
I want to pass 2 values from A Form to B Form, and B Form only shows the matching data. How can I put these 2 values togother? I tried to use "+" or "and" or "||", but they are wrong. Please help me! Thank you.
stLinkCriteria = "[IndexCode]=" & "'" & Me![IndexCode] & "'"
stLinkCriteriaa = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
Private Sub ComOpenSelect_Click()
On Error GoTo Err_ComOpenSelect_Click
Dim stDocName As String
**
Dim stLinkCriteria As String
Dim stLinkCriteriaa As String
**
stDocName = "FRM_EditProjects"
**
stLinkCriteria = "[IndexCode]=" & "'" & Me![IndexCode] & "'"
stLinkCriteriaa = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
** DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ComOpenSelect_Click:
Exit Sub
Err_ComOpenSelect_Click:
MsgBox Err.Description
Resume Exit_ComOpenSelect_Click
End Sub
Cindy
|
|

October 5th, 2010, 12:38 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
|
|
Quote:
Originally Posted by cindyl
Hi everyone, please help me.
I want to pass 2 values from A Form to B Form, and B Form only shows the matching data. How can I put these 2 values togother? I tried to use "+" or "and" or "||", but they are wrong. Please help me! Thank you.
stLinkCriteria = "[IndexCode]=" & "'" & Me![IndexCode] & "'"
stLinkCriteriaa = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
Private Sub ComOpenSelect_Click()
On Error GoTo Err_ComOpenSelect_Click
Dim stDocName As String
**
Dim stLinkCriteria As String
Dim stLinkCriteriaa As String
**
stDocName = "FRM_EditProjects"
**
stLinkCriteria = "[IndexCode]=" & "'" & Me![IndexCode] & "'"
stLinkCriteriaa = "[ProjectName]=" & "'" & Me![ProjectName] & "'"
** DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ComOpenSelect_Click:
Exit Sub
Err_ComOpenSelect_Click:
MsgBox Err.Description
Resume Exit_ComOpenSelect_Click
End Sub
Cindy
|
Cindy,
Try this:
Code:
Private Sub ComOpenSelect_Click()
On Error GoTo Err_ComOpenSelect_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteriaa As String
stDocName = "FRM_EditProjects"
stLinkCriteria = "[IndexCode]= " & Chr(34) & Me![IndexCode] & Chr(34)
stLinkCriteria = stLinkCriteria & " and [ProjectName]=" & Chr(34) & Me.[ProjectName] & Chr(34)
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ComOpenSelect_Click:
Exit Sub
Err_ComOpenSelect_Click:
MsgBox Err.Description
Resume Exit_ComOpenSelect_Click
End Sub
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
|
|
The Following User Says Thank You to HiTechCoach For This Useful Post:
|
|
|

October 5th, 2010, 10:19 AM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
|
|
Not working, the filter only got IndexCode
Thanks, but filter only got this, so I got no data show up(I don't have null value on ProjectName field):
***
[IndexCode]= "580878" and [ProjectName]=""
***
IndexCode is correct.
On the Form A, IndexCode is Combo box, and ProjectName is List box.
Please help me.
Many things,
Cindy
|
|

October 6th, 2010, 08:28 PM
|
|
Authorized User
|
|
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
|
|
It works
Thanks, HiTechCoach, your code is working.
Sorry I put bound column=2 before, so it wasn't working; After I change 2 to 1, it works.
Many Thanks,
Cindy
|
|

October 6th, 2010, 08:52 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
|
|
Cindy,
You're welcome.
Glad to assist.
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
|
|
The Following User Says Thank You to HiTechCoach For This Useful Post:
|
|
|
 |