473,698 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to give a value of textbox in query

21 New Member
hi guys,
I have a combobox and i want to use that value in query
suppose I have form in that i have textbox and combo box
and button. And I have code like this in button onclick event.

Code:

Expand|Select|Wrap|Line Numbers
  1. If Combo2.Value = "Department" Then
  2. strSQL = "select distinct * from Laptops where Department like '*" & txtKeyword.Value & "*'  "
  3. Me.SubLaptops.Controls.Item("txtQuantityOrdered") = DSum("[quantity ordered]", "Laptops", "[Department] like '*" & txtKeyword.Value & "*'")

but i want make query of this code how can i do?
Expand|Select|Wrap|Line Numbers
  1. DSum("[quantity ordered]", "Laptops", "[Department] like '*" & txtKeyword.Value & "*'")
i want to pass the value of textbox in query.
i tried like this

Expand|Select|Wrap|Line Numbers
  1. select sum[quantity order] from laptop
  2. where [comboox value] = "whatever User Select the value from combobox " & [textbox value] =" whatever user type"

Thanks a lot.
Jun 2 '11 #1
2 2512
Mihail
759 Contributor
Create a PUBLIC function:
Expand|Select|Wrap|Line Numbers
  1. Public Function WhereClause() as String
  2.     WhereClause = YourForm.YourComboBox.Text & YourForm.YoutTextBox.Text
  3. End Function
In the "Criteria" row of your query write: WhereClause()

Of course the name of the function can be anything else.

I am sure that exist an easy way but I am not skilled enough in Acces VBA.

Good luck !
Jun 3 '11 #2
NeoPa
32,569 Recognized Expert Moderator MVP
That is one good answer. Another is to refer to the item specifically within your SQL (See Referring to Items on a Sub-Form for more on this) :

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT DISTINCT * " & _
  2.          "FROM Laptops " & _
  3.          "WHERE "Department Like '*" & Forms("Formname").txtKeyword.Value & "*')"
Jun 3 '11 #3

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

Similar topics

1
719
by: Chuck | last post by:
I have a query that uses the query with the critera set to . We I run the query the msgbox pops up asking for the name information to be entered, but on the top (blue background) of the message box it says" Enter Parameter Value ". Is there anyway to change this to something that is not as generic. I appreciate any help you can give. Thanks Chuck
0
273
by: Patrick De Ridder | last post by:
I posted this query before, but am not seeing it listed. If I enter a return in a text entered into a textBox, the rest of the text gets lost after a write textBox.Text and a read textBox.Text. Is there a better solution than blocking Enter? Patrick.
3
13726
by: VB Programmer | last post by:
In my ASPX page how do I get the .text value of a textbox that is in the ItemTemplate of a datalist (using HTML)? The textbox contains the quantity for a shopping cart item. The textbox is called "txtQty" and the current HTML is this (I need to replace xxxx with the text value from the textbox): <A href='UpdateCart.aspx?CartId=<%# DataBinder.Eval(Container.DataItem, "CartID") %>&Qty=xxxx'><IMG src="Resources/UpdateBtn.jpg"...
2
3994
by: dath | last post by:
Hi, Searched the forum and found a lot on passing form input to aquery but not the other way around. Here is the situation: I have a timesheet form based on a subform query that asks the user for the Month and their last name. The fields in the table being updated include: FY, Month, Employee ID, Task Number, hours. The query then displays the results in data sheet view on the form. I have been asked by users to display total they...
14
2472
by: sudheerk | last post by:
please give me a query for already existing name in the data base using mysql
10
1769
by: arial | last post by:
Hi all, I need some help on retrive the value from query string. I have two web forms. One has the datagridview which displays the data from database. On one of the column I made a hyperlink to go to next page like, qi.aspx?qi_track={0} and now I need to open a detail of this qi_track on second page. how can I extract the value of qitrack from the url.
11
5441
by: prisesh26 | last post by:
hi, iam passing a name "sun & moon" in my query string as a parameter. but when i receive it through request.getParameter iam getting only sun. rest are getting ignored due to & symbol. how to get the value as wat i entered through query string. encoding with another symbol is not adviced. so can any one give a good solution please help me soon as possible .
5
3733
by: ellie | last post by:
Hello I have a table (MainTable) with the fields (PK)ID (cbo)from_dept document_date reference_number last_reference I have a query on the first 4 fields that is sorted to give the last reference_number for each from_dept This is the value I need to be automatically displayed in last_reference when the from_dept is selected from it's cbo The idea being that when I enter a new record I select from_dept and the last_reference for that...
7
11352
by: Ken Jones | last post by:
Can this conversion be done using Microsoft Access? If so how? Could this be done using TRANSFORM and PIVOT SQL statements? The Old Format columns are NO and URL The New Format Columns are No, User1URL and User2URL Old Format NO URL 16 http:/16_User1.html 16 http:/16_User2.html 18 ...
3
6791
by: JenniferM | last post by:
Annnnnd I'm back again, with a new problem, of course. I've got a table, TblKneeExamInfo, which corresponds to a form, FrmKneeExamInfo. In it, there is a section where I need to input patient answers for questions regarding pain, swelling, etc (These are all numeric values ranging from 0-4). Currently I have a query set up that calculates the overall subscore for a particular group of questions, say for those regarding pain. This is the SQL...
0
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.