Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Input box value in sql statement

Status
Not open for further replies.

blindlemonray

Technical User
Nov 24, 2003
130
GB
Hi All,

I am trying to pass a value to a SQL statement by way of an inputbox, but I can't seem to get it working. I cannot seem to pass the value from the inputbox into the = part of the sql statement.

Can anyone point me in the right direction?

Code:
Dim strCode As String
Dim sSQLdelete As String
strCode = InputBox("Please confirm client code for deletion", "Client Deletion")

 sSQLdelete = "DELETE Plan_norm.* From Plan_norm WHERE (Plan_norm.Code)= strCode"

DoCmd.RunSQL sSQLdelete
DoCmd.OpenForm "Master_plancheck_frm", acNormal


Have also tried

Code:
 sSQLdelete = "DELETE Plan_norm.* From Plan_norm WHERE (Plan_norm.Code)=" & strCode

and variations thereof.

thanks in advance

BLR [2thumbsup]
 
What about this ?
Code:
sSQLdelete = "DELETE FROM Plan_norm WHERE Code='" & strCode & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
in order to debug this you need
debug.print sSqlDelete
prior to executing you code

Now look at the sql string and show us what it resolves to. This should be standard practice when writing code.
 
thanks PHV works a treat. Looks like I may have got there eventualy but you saved me a lot of time.

Hi MajP, I am self taught so standard practices are not something I am aware of, but I will use this from now on. Thanks for the tip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top