473,406 Members | 2,707 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,406 software developers and data experts.

Add Items From A Database

i have created a program that when a user types data , it will search for it, when the user searches for it, i want to make it so the user can add the item and remove the item if they wanted to.

my coding so far is

Private Sub cmdSearch_Click()
If opt1 Then
Data1.RecordSource = "SELECT * FROM [Table] WHERE [Reference]='" & CStr(txtSearch.Text) & "'"
Data1.Refresh
End If

If opt2 Then
Data1.RecordSource = "SELECT * FROM [Table] WHERE [Item]='" & CStr(txtSearch.Text) & "'"
Data1.Refresh
End If

If opt3 Then
Data1.RecordSource = "SELECT * FROM [Table] WHERE [Item Description]='" & CStr(txtSearch.Text) & "'"
Data1.Refresh
End If

If opt4 Then
Data1.RecordSource = "SELECT * FROM [Table] WHERE [Quantity]='" & CStr(txtSearch.Text) & "'"
Data1.Refresh
End If

If opt5 Then
Data1.RecordSource = "SELECT * FROM [Table] WHERE [Price]='" & CStr(txtSearch.Text) & "'"
Data1.Refresh
End If

txtSearch.Text = ""
DBGrid1.Visible = True
End Sub
Nov 22 '07 #1
8 1597
lotus18
866 512MB

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.  
  3. If opt1.Value = 1Then
  4.      Data1.RecordSource = "SELECT * FROM [Table] WHERE [Reference]='" &   CStr(txtSearch.Text) & "'"
  5.      Data1.Refresh
  6. ElseIf opt2.Value = 1 Then
  7.      Data1.RecordSource = "SELECT * FROM [Table] WHERE [Item]='" &  CStr(txtSearch.Text) & "'"
  8. Data1.Refresh
  9. ElseIf opt3.Value = 1 Then
  10. Data1.RecordSource = "SELECT * FROM [Table] WHERE [Item Description]='" & CStr(txtSearch.Text) & "'"
  11. Data1.Refresh
  12. ElseIf opt4.Value = 1 Then
  13.      Data1.RecordSource = "SELECT * FROM [Table] WHERE [Quantity]='" &    CStr(txtSearch.Text) & "'"
  14.      Data1.Refresh
  15. Else
  16.      Data1.RecordSource = "SELECT * FROM [Table] WHERE [Price]='" & CStr(txtSearch.Text) & "'"
  17.      Data1.Refresh
  18. End If
  19.  
  20. txtSearch.Text = ""
  21. DBGrid1.Visible = True
  22. End Sub
  23.  
Hi

Is this working?
Try the Insert and Delete
Nov 22 '07 #2
yes the program does work.
Nov 22 '07 #3
lotus18
866 512MB
yes the program does work.
Here's an example for inserting and deleting a record

Expand|Select|Wrap|Line Numbers
  1.  
  2. "Insert Into <TableName> ([<FieldName>]) Values ('" & Text1.Text &  "')"
  3.  
  4. "Delete From <TableName> Where <FieldName>='" & Text1.Text & "'"
  5.  
  6.  
Note:

Omit < and >. For deleting an item, it is recommended to used the primary key in the given sample above
Nov 22 '07 #4
so does that add/delete the row onto a new database?
Nov 23 '07 #5
lotus18
866 512MB
so does that add/delete the row onto a new database?
Hi Gemmalouise1988

Nope. This is not for creating a new database but this is for adding/deleting a record from your existing database. Or do I misinterpret your post?
Nov 23 '07 #6
sorry i think i didnt explain it properly lol

i have one database listing all the items

and then another one so when the user decides to buy an item, it shows what she has bought, and i would like it so if the user decided they didnt want a certain item they could remove it.
Nov 23 '07 #7
lotus18
866 512MB
sorry i think i didnt explain it properly lol

i have one database listing all the items

and then another one so when the user decides to buy an item, it shows what she has bought, and i would like it so if the user decided they didnt want a certain item they could remove it.
I think you have to create a temporary list of items probably using a listvwiew or listbox, etc to let you view all the items you selected so that you can select the items you want to delete, then when it is final thats the time you save it to your database. btw, pinoy ka?
Nov 23 '07 #8
ahhh right, i get it

THANK YOU!!!
Nov 23 '07 #9

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

Similar topics

1
by: R.G. Vervoort | last post by:
Not sure if this is javascript or php so i put it in both newsgroups, sorry if it's the wrong group. I wrote (with help) a code to put several items in a list object (select) and I would like to...
2
by: Diggler | last post by:
I have a group of items in the database that need to be sorted by the client. There is a field in the database that stores the desired order (0, 1, 2, etc...). I would like to allow the client to...
3
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
1
by: Srinivasa Rao | last post by:
I have binded the two datagrids from database from two different tables. In both datagrids, the first column contains checkbox. In between the datagrid, i have "Add -->" and "Remove -->" buttons in...
2
by: TS | last post by:
Hi all, From my windows form, I opened a connection to a SQL database. Now I need to generate a combo box from a SELECT statement pointing to the last name column in the SQL tables. I am stuck...
2
by: John | last post by:
I have a listbox that is databound when my form loads. A user can then select and option using a drop down box. When the user selects an option the corresponding items in the listbox gets selected....
7
by: Barkster | last post by:
I'm trying to list my categories and how many items are in each category. I'm not much on sub queries. How can I combine these two items. I'd like to display the category and the corresponding...
3
by: Ray Booysen | last post by:
Hi all I have a treeview bound to a sitemap. Once the user is logged in, I'm wanting the menu to expand to include additional items from a database while retaining the items in the sitemap. Is...
3
by: jmDesktop | last post by:
Hi, probably a simple question that I have for what I think is a simple database. I have a Vendors table and an Items table. There is only one items, but several Vendors may have that same item. ...
3
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
I've a multiview with 3 views. on view 2 the user is presented with a check box list (items from database) at view 3 the user can review their selections and, either post to the database or go back...
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?
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:
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.