473,289 Members | 2,106 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,289 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 3531
isladogs
454 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
454 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...
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: 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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.