Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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
 
Old October 4th, 2010, 03:27 PM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Default 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
 
Old October 5th, 2010, 12:38 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Quote:
Originally Posted by cindyl View Post
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:
cindyl (October 6th, 2010)
 
Old October 5th, 2010, 10:19 AM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Question 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
 
Old October 6th, 2010, 08:28 PM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Smile 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
 
Old October 6th, 2010, 08:52 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

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:
cindyl (October 7th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access values from different windows forms? chobo2 C# 2008 aka C# 3.0 17 September 15th, 2008 05:31 PM
How to pass values between different pages dipanjan22 ASP.NET 1.x and 2.0 Application Design 4 September 30th, 2007 02:02 PM
how to pass data between asp.net forms hemanshubhojak ASP.NET 1.0 and 1.1 Professional 1 August 14th, 2005 12:27 AM
pass hidden values X-Ken VS.NET 2002/2003 2 September 8th, 2004 07:38 AM
cannot pass parameters between forms deerebuck BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 February 15th, 2004 05:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.