473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 15139
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

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

Similar topics

4
by: John Baker | last post by:
Hi: I have a MACRO and as one step in it I am opening a form, which is based on a query. The query calls for entry of a portion of an associates name as the selection criteria for records. Using...
0
by: samuel | last post by:
Hi I wrote a macro in MS Access 2000. This is a .adp link on SQL server tables. I have 2 forms: script_selection & Form3 Form3 include 2 important fields: CD & line I want to write a...
9
by: Tony Williams | last post by:
I have two tables 1.tblmonth which holds two fields txtmonth and txtqtrlabel and 2. tblmain which holds a number of fields but in particular a field called txtqtrlabel2. The two tables are linked...
8
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but...
1
by: Thierry Lam | last post by:
Let's say I have the following codes: #define macHOME $HELLOHOME How can I concatenate the above macro into a string, for example I want the following result: char *path =...
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
16
by: KayCee | last post by:
Hello All - I'm new to the community. I have been asked to move the used of a database I created from a record in a table to the corresponding record of a form. After much research and trial &...
81
by: ljungers | last post by:
Are the Action(s) in a Macro run in sequence? How would a OpenQuery pass it's results to a OpenForm that followed in the action list? For example I have a form #1 that contains a couple of text...
4
by: apartain | last post by:
I have a macro with several actions in it. They each have a condition. The macro seems to be working for the first line of action, but not for any of the subsequent actions. Any ideas why this may...
15
by: chuck gregory | last post by:
I'm trying to make a macro. When I enter the field on the form I'm working in, I want to open up another form to check the child's name. Trying to create the macro, I enter the where condition data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.