473,386 Members | 1,715 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.

Query Data in a Form

222 100+
How can i run a query using VB code to search a value in ms access form ( subform) the query that is selected isn't related to relationship but it is in the same file . thank u
Apr 6 '07 #1
3 1291
maxamis4
295 Expert 100+
Well First you have to be familar with recordsets and there functionality. Thats step one. I will give you a template to follow but you must take the time to go out and read up on some of this, or else it will never make sense.

Expand|Select|Wrap|Line Numbers
  1. dim rst as recordset
  2. dim db as database
  3. dim mysql as string
  4.  
  5. 'Set your sql statement here
  6. mysql "SELECT * FROM [YOUR TABLE]" _ 
  7.           & "WHERE([YOUR_VALUE])= '" & searched value & "'"
  8. 'Mind you if the variable you are searching is a number you don't need the apostrophy ' if it is a string you need to enclose the apostropy  at both ends
  9.  
  10. Set db = CurrentDb()
  11. Set rs = db.OpenRecordset(mysql, dbOpenDynaset)
  12.  
  13. your_text_box = rs![Value] 'Value being the primary key of the record you are searching for, or any record based on that criteria.
  14.  
  15. set rs = nothing
  16.  
  17.  
this should be a start for you good luck. Research recordsets
Apr 6 '07 #2
NeoPa
32,556 Expert Mod 16PB
How can i run a query using VB code to search a value in ms access form ( subform) the query that is selected isn't related to relationship but it is in the same file . thank u
As you have expressed the question - you can't.
Forms are not containers of data but simply enable views of data in recordsets (Tables or Queries).
You should consider rewording your question in such a way as to make sense (FAQ - How to Ask a Question). If help is required to query a particular table, then you need to share some information about that table.

MODERATOR.
Apr 12 '07 #3
wassimdaccache
222 100+
OK I 'll clear my question ... I have a master link form contains a customerID and invoiceID based on INVOICES_TABLE they are primary key. The subform is linked to this 2 primary keys that is based to the PRODUCT_INFO_TABLE. What I need to know is when I add a new product in the subform I want to find the last cost (if exisit) in the PRODUCT_INFO_TABLE that is related to the customerID in the form .


I was working with recordset but the problem is when I use INNER JOIN I won't be able to open the recordset ....


thank you very much for ur help byyyyyyyyyy
Apr 15 '07 #4

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

Similar topics

3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
0
by: Jason | last post by:
I have a primary form which is used to enter/edit data in a table named Test_Results. On this primary form there is a subform which displays site addresses. This subform is linked to the primary...
18
by: Wim | last post by:
Hi, I would like to make and put a query in my database by VB.NET code. Is this possible? Thanks for your help, wim
6
by: ljungers | last post by:
Hi to all and hope someone may have an answer for me. I have a Form named Cust_lukup_Form that has 3 text boxes and a click button that uses a OnClick to call Cust_lukup_Macro that runs an...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
4
by: Scott12345 | last post by:
Hi, here is my situation, I have a DB that tracks machine downtime (30 machines) per day. Several users will update this through the day. I created an append query that creates 30 dummy values and...
2
by: lindabaldwin | last post by:
Hello everyone, I am fairly new to VBA. I have a worksheet in Excel, named "Data Sheet" from which I am trying to query data. This worksheet contains the following data: unit (column A), date...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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.