473,387 Members | 1,687 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,387 software developers and data experts.

Need to Filter Query with textbox

Okay, so I know this sounds easy, but for some reason I'm having alot of trouble working this out. I've looked for the answer on other posts, but nothing has worked.

I have a form with a text box ("txtbox1"). When this number is updated with the update function I want it to filter a query WHERE [Field] = "txtbox1" value.

The query is displayed in a subform. It draws its information from one table.

My code is a mess right now so I won't post it. I can answer any questions though.

Thank You
Aug 8 '12 #1

✓ answered by twinnyfo

It was unclear as to whether this field was a text or a number. It appears to be a number. Try removing the single quote in the expression, like so:

Expand|Select|Wrap|Line Numbers
  1. Me.rxQuery.Form.Filter = "[Rx Number] = " & rxNum
  2.  
Also, as a gentle reminder, please use the code tags when posting your code.

Hope this helps, my friend.....

4 5152
twinnyfo
3,653 Expert Mod 2GB
Proper syntax should be:

Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM tblTableName WHERE [Field] = '" & Me.txtbox1 & "';"
  2.  
If you are just filtering the subform, you can filter the subform directly fromthe main form:

Expand|Select|Wrap|Line Numbers
  1. Me.fsubFormName.Form.Filter = "[Field] = '" & Me.txtbox1 & "'"
  2. Me.fsubFormName.Form.FilterOn = True
  3.  
I think this is the direction you want to go?
Aug 8 '12 #2
Okay well I'm getting a "Data type mismatch in criteria expression"

I tried putting the textbox name and value variable name.

'Variable for aRxNumber textbox
Dim rxNum As Long
rxNum = Val(Nz([Form_Log Form].aRxNumber.Value, 0))

Me.rxQuery.Form.Filter = "[Rx Number] = '" & rxNum & "'"
Me.rxQuery.Form.FilterOn = True
Aug 8 '12 #3
twinnyfo
3,653 Expert Mod 2GB
It was unclear as to whether this field was a text or a number. It appears to be a number. Try removing the single quote in the expression, like so:

Expand|Select|Wrap|Line Numbers
  1. Me.rxQuery.Form.Filter = "[Rx Number] = " & rxNum
  2.  
Also, as a gentle reminder, please use the code tags when posting your code.

Hope this helps, my friend.....
Aug 8 '12 #4
It worked! Thank you again for the help and guidance.
Aug 8 '12 #5

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

Similar topics

1
by: Don | last post by:
Is there a way to query the value of an open form's textbox? I am trying to append the values from a form to a table.
5
by: Darren Smith | last post by:
Hi There, I have a shopping cart app that displays products along with a textbox (to enter quantity) and an image button to add the item to the shopping cart. Please explain why my below...
0
by: vinod | last post by:
Dear experts i need a query like this i have a table like this. accno name amount running_total 1 a 50 50 2 ...
8
by: annecarterfredi | last post by:
query the syscat.columns table and prepare SELECT statement (SELECT all_columns FROM table_name). For example, let's say that TAB_1 table has total of three columns, and the statement should be: ...
5
by: djpaul | last post by:
Hello, I trying to make an program for my cd collection. I wanted to insert all my cd's into a access database. Then, with the program, i want to search for a title or artist. So, my question is,...
5
by: Karthik D V | last post by:
Hello All, I have a table like this ID CHARACTER ----------- --------- 1 A 2 A 3 B 4 B
8
by: Gari | last post by:
Hello, I am trying to build a filter query with some AND and OR. I have three text boxes and 5 check boxes. The checkboxes are linked via code to other textboxes for the purpose of the query. ...
1
by: AccessNewbie | last post by:
Hello: I have a form (frmMain) that I have included a subform (frmSubForm) on. What I need on the MAIN form are command buttons that will filter the information on the SUBFORM. It is very...
4
by: muhammadrashidmughal | last post by:
columns f1 f2 f2 f4 f5 f6 f7 f8 ...... 1 2 3 4 ...
3
by: NewbieAccessor | last post by:
Hello! I have only been using Access for 24 hours and need some help!! I have a Query that has totalled the number of unique Projects allocated to my group. This is good! Now, this total, I...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.