469,306 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

How to Concatenate WHERE condition of OPENFORM MACRO or VBA?

132 100+
Hi all!
I have a form named Form1, from there I can open another form named frmModules by using OPEN_FORM MACRO at OnClick Event of ComandButton as follows
Expand|Select|Wrap|Line Numbers
  1.  OpenForm
  2.         Form Name:      frmModules
  3.         View:           Datasheet
  4.         WHERE CONDITION:="[ModID]=" & [ModuleID]
  5.         Data Mode:      Edit 
  6.         Window Mode:    Normal 
  7.  
With this MACRO I can Open frmModules which shows the data equivalent to the one selected from Combobox ModuleID from Form1 WHERE Forms!Form1!ModuleID=Forms!frmModules!ModID
Question:
How can I CONCATENATE the WHERE CONDITIONS to include more Criteria?
Example OPEN frmModules WHERE
1. Forms!Form1!ModID=Forms!frmModules!ModuleID
2. Forms!Form1!CustomerID=Forms!frmModules!CustomerID
3. Forms!Form1!ProductsName=Forms!frmModules!Products Name
Please help!!!
Dec 23 '10 #1

✓ answered by mshmyob

I don't use macros bu try something like so
Expand|Select|Wrap|Line Numbers
  1. "[ModID]=" & [ModuleID] & " AND [CustomerID]=" & [CustomerID] & " AND [ProductsName]='" & [ProductsName] & "'"
  2.  
cheers,

7 14536
mshmyob
904 Expert 512MB
I don't use macros bu try something like so
Expand|Select|Wrap|Line Numbers
  1. "[ModID]=" & [ModuleID] & " AND [CustomerID]=" & [CustomerID] & " AND [ProductsName]='" & [ProductsName] & "'"
  2.  
cheers,
Dec 23 '10 #2
Mr Key
132 100+
It could work in my db, how about this & "'" on the end of that lineCode? What does it stand for?
Is there any other alternative solution for this?
Dec 23 '10 #3
mshmyob
904 Expert 512MB
Just enclosing strings in quotes. I assume ProductsName is a string.

cheers,
Dec 23 '10 #4
Mr Key
132 100+
It works only with two Variables like
[CustomerID]=" & [CustomerID] & " AND [ProductsName]='" & [ProductsName] & "'"
If you add the third one it Doesnt!
I wish I could have all three WHERE conditions!
Help again!!!
Dec 23 '10 #5
mshmyob
904 Expert 512MB
Doesn't work???

You have to give me more details than that.

Note: I assumed CustomerID was numeric - if it is text then you have to enclose that in quotes also.

cheers,
Dec 23 '10 #6
Mr Key
132 100+
Thanks alot myshomb!
Finally it works!!
I just missed the Quotes between the field!
Thanks again!
Dec 23 '10 #7
mshmyob
904 Expert 512MB
You're welcome. Good luck with the rest of your project.

cheers,
Dec 23 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Tony Williams | last post: by
1 post views Thread by Thierry Lam | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.