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

SQL asks for additional parameter

daoxx
32
Hi
I've had this problem before and it got solved, except it was with numeric values.
This time it's with text, and I'm doing it as I did with the numbers.. But it isn't working.

I have this code in a button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelName_Click()
  2. Dim sql2 As String
  3. Dim n As String
  4. n = InputBox("Which name do you want to remove?", "Remove name")
  5. sql2 = "DELETE * FROM Names WHERE [Name]=" & n
  6. DoCmd.SetWarnings False
  7. DoCmd.RunSQL sql2
  8. DoCmd.SetWarnings True
  9. Me.NameSt.Requery
  10. Me.NameEnd.Requery
  11. End Sub
It shows me the inputbox, then asks me for a parameter. If I input John on the inputbox and John when SQL asks me for a parameter, it will delete John.
The problem here is that I don't want the parameter box to show up asking me for the same thing.

Thanks for any assistance.
Apr 8 '08 #1
2 1282
MikeTheBike
639 Expert 512MB
Hi
I've had this problem before and it got solved, except it was with numeric values.
This time it's with text, and I'm doing it as I did with the numbers.. But it isn't working.

I have this code in a button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelName_Click()
  2. Dim sql2 As String
  3. Dim n As String
  4. n = InputBox("Which name do you want to remove?", "Remove name")
  5. sql2 = "DELETE * FROM Names WHERE [Name]=" & n
  6. DoCmd.SetWarnings False
  7. DoCmd.RunSQL sql2
  8. DoCmd.SetWarnings True
  9. Me.NameSt.Requery
  10. Me.NameEnd.Requery
  11. End Sub
It shows me the inputbox, then asks me for a parameter. If I input John on the inputbox and John when SQL asks me for a parameter, it will delete John.
The problem here is that I don't want the parameter box to show up asking me for the same thing.

Thanks for any assistance.
Hi

As Name is a text field in the table, then perhaps (just perhaps) this may help

sql2 = "DELETE * FROM Names WHERE [Name]= '" & n & "'"

ie. for text field values (n in this case) need to be delimited by apostophes, so that VB knows where the string value starts and ends (this is self evident with numbers !).

HTH


MTB
Apr 8 '08 #2
daoxx
32
Works perfectly, and now that I think of it.. I've made this error several times!
I've to write it down ;d

Thanks :D
Apr 8 '08 #3

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

Similar topics

2
by: Ashutosh | last post by:
Our company has an intranet paging website. It gets all the contact and group addresses from SQL Server database. The paging is done through WCTP. It works properly except for only one group where...
2
by: Remco Groot Beumer | last post by:
Hello, I've developed a Microsoft Access 2000 database. In a lot of events Docmd.RunSQL is used. In my database options the 'Confirm' options are turned off, so I don't have to confirm action...
2
by: tina.boroff | last post by:
I have a combo box that gathers insurance company names from my CCtable. If you add a name that isn't in the list it: 1)asks if you want to add the company 2)if so opens up the CCform (based on...
5
by: Jamie Oglethorpe | last post by:
I would like to create a new exception class with an additional parameter, something like this: public class MyException: Exception { private String field = ""; public void MyException(String...
2
by: Hazzard | last post by:
I am trying to figure out how to add an additional value to a querystring collection so that when I click on a datagrid cell, there will be a key to distinguish it from another column's...
6
by: Anita | last post by:
I have problem opening my existing projects or newly created project. It asks me for user name and password and if I provide then it allows me to open but when I debug either it gives error message...
4
by: pawel.pabich | last post by:
Hajo, I use <customeErrors> and I set the defaultRedirect attribute to my error page. Now I want to pass to this page additional number and I want to do this using query string but I do not...
5
by: Vinay | last post by:
Hi, I have created a Context Menu class (CMenu) with relevant items. Based on a selected Item, I am taking a separate action. The following code is working fine. CMenu(sOption as string)...
2
by: trixxnixon | last post by:
ok i have a query that pulls its parameters from a form. If a filed on the parameter form is blank, or is null, the query will search without using a parameter. To do this I use the !! or (!!is...
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
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?
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
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
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...
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...

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.