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

Cannot pass data to sql delete criteria

2 2Bits
Hi Everyone
Im struggling to pass a form value to a public sub sqlstring, when I reference the form directly, it works...

Expand|Select|Wrap|Line Numbers
  1. Public Sub CalDeleteTopSheet(strCal As String)
  2.  
  3. Dim strSqlDelete As String
  4.  
  5. strSqlDelete = "DELETE " & strCal & ".Summary" & vbCrLf & _
  6. "FROM " & strCal & vbCrLf & _
  7. "WHERE (((" & strCal & ".Summary)= [Forms]![NewTopSheet]![txtCustomerID] ));"
  8.  
  9. End Sub
  10.  
When I substitute the form reference [Forms]![NewTopSheet]![txtCustomerID] for strID I get a datatype mismatch error...

Expand|Select|Wrap|Line Numbers
  1. Public Sub CalDeleteTopSheet(strCal As String, strID As String)
  2.  
  3. Dim strSqlDelete As String
  4.  
  5. strSqlDelete = "DELETE " & strCal & ".Summary" & vbCrLf & _
  6. "FROM " & strCal & vbCrLf & _
  7. "WHERE (((" & strCal & ".Summary)= " & strID & "));"
  8.  
  9. End Sub
  10.  
I checked the datatype of both strID and strCal they're both strings
The table field thats being referenced for deletion strCal.Summary is in long text, do I need to convert strID to long text, not sure how to do it.

Thank you so much in advance

Cheers Eddie
Jun 15 '21 #1

✓ answered by isladogs

You need to use single quotes around the strID variable
Expand|Select|Wrap|Line Numbers
  1. . . .  ='" & strID &"'));"

4 3528
isladogs
451 Expert Mod 256MB
You need to use single quotes around the strID variable
Expand|Select|Wrap|Line Numbers
  1. . . .  ='" & strID &"'));"
Jun 15 '21 #2
NeoPa
32,554 Expert Mod 16PB
It looks like you may benefit from reading Quotes (') and Double-Quotes (") - Where and When to use them.

Essentially IslaDogs is on the money, though you need to understand the difference between the handling of literal values within SQL and the handling of references. The form reference - is a reference of course. The value however, is a literal value and needs to be handled differently in order for the SQL engine to properly understand what it is you're asking it to do.
Jun 15 '21 #3
Eddie2020
2 2Bits
Argh... Thank you Isla, and thank Neo for the link, I will take best practices on!
Cheers Eddie
Jun 15 '21 #4
isladogs
451 Expert Mod 256MB
No problem. You're welcome
Jun 16 '21 #5

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

Similar topics

4
by: Gerhard Pretorius | last post by:
ON Win 2003 IIS6, Since yesterday, (12 Aug 2003) for some strange reason, (after installing WindowsServer2003-KB823980-x86-ENU.exe) I cannot pass the Request object to to VB COM DLL. I have...
2
by: Matt | last post by:
How to pass data back and forth between ASP and JSP page? Let's say I have Java objects, how to pass the data back to ASP page?? Or ASP has data, how to pass the data to JSP page?? Please...
0
by: Matt | last post by:
My problem is to allow ASP to interact with JSP, and I pass JavaScript object in my approach, but I wonder if it will work in network, not just in local machine. For testing purposes, the...
7
by: Matt | last post by:
In ASP, when we pass data between pages, we usually pass by query string. If we pass data by query string, that means we need to use submit button, not by regular button, and the form will pass to...
8
by: Vijay | last post by:
Hi all, Im using gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) on 64bit linux server im trying to compile following code --------------------sam.cpp--------------------- #include...
2
by: Mountain Bikn' Guy | last post by:
It is known that one cannot pass arguments as ref or out in a marshal-by-reference class. My problem is that I have a C DLL (and C# wrapper) that I need to isolate in an AppDomain and then I need...
0
by: Holger Marzen | last post by:
I had tomatoes on my eyes. I wrote laufverke but meant laufwerke. Sorry. ---------- Forwarded message ---------- Date: Mon, 12 Jul 2004 15:03:14 +0200 (CEST) From: Holger Marzen...
2
by: Anil Pundhir | last post by:
What is the best way to pass data to a web service. The client(to send data) has .net environment and also the server on which the web service is hosted also has the .net environment. Should I...
2
by: John Kelsey | last post by:
I am an old, longtime C programmer surprised and confused by an error message I'm getting from my VS2005 compiler... "Cannot pass 'Item' as a ref or out argument because it is a 'foreach...
3
Frinavale
by: Frinavale | last post by:
I've created a few ASP.NET Ajax Enable Server controls. There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.