Customise Where Condition

satoshi79

New member
Local time
Tomorrow, 02:37
Joined
May 25, 2003
Messages
5
Hi there,

Please refer to this line of code below:

DoCmd.OpenForm "frmBuyersInterestedPropertiesDirectory", acNormal, , "[BuyerID]='" + Me![BuyerID] + "'"

I have tried to customise this (where) statement to display "frmBuyersInterestedPropertiesDirectory" from
frmBuyerPropListing when the BuyerID and PropertyID are the same for both forms.

How do I include PropertyID into the statement above?

Any suggestions?

Thank you.
satoshi
 
Satoshi,

Give this a try and let me know how you get on. I use this a lot on my DB.

DoCmd.OpenForm "frmBuyersInterestedPropertiesDirectory" 'Open the form
Forms!frmBuyersInterestedPropertiesDirectory!PropertyID.SetFocus 'Sets focus on the PropertyID field'
DoCmd.FindRecord Forms!frmBuyerPropListing!BuyerID 'Go to the record with the corresponding ID from the current form

HTH
Andrew
 
Andrew, you might consider changing your method. The where argument of the OpenForm method is more flexible. Your method requires that the report be opened from only a single form. Using the where method, the report is not tied to a single form.

satoshi79, the proper concatenation operator for VBA is the ampersand (&). The plus sign (+) will function as a concatenation operator under certain conditions but it has different properties so it is best to use the & unless you need a specific property of the +.

DoCmd.OpenForm "frmBuyersInterestedPropertiesDirectory", acNormal, , "[BuyerID]='" & Me.BuyerID & "' AND [PropertyID] = " & Me.PropertyID

If PropertyID is also text, you will need to surround it with quotes as you did for BuyerID.
 
Many thanks for the tip Pat, I wasn't even aware there was another method. And sorry for leading you astray Satoshi!
 

Users who are viewing this thread

Back
Top Bottom