Missing Operator syntax error is SQL VB code

Missing Operator syntax error is SQL VB code

am 05.04.2008 04:54:41 von g_k_harrison

Hi. I have a button - Command9 with the Click event to run this code
on a form called frmSelforDel.

Dim SQL1 As String
DoCmd.SetWarnings False
SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"

On that same form is a text box named txtDel with a set value. 260Land
is a table with 260ID as a column.

I'm not knowledgeable enough to get the syntax correct on this
statement. Please help. Thank you!

Greg.

Re: Missing Operator syntax error is SQL VB code

am 05.04.2008 06:05:23 von DFS

g_k_harrison@yahoo.com wrote:
> Hi. I have a button - Command9 with the Click event to run this code
> on a form called frmSelforDel.
>
> Dim SQL1 As String
> DoCmd.SetWarnings False
> SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"
>
> On that same form is a text box named txtDel with a set value. 260Land
> is a table with 260ID as a column.
>
> I'm not knowledgeable enough to get the syntax correct on this
> statement. Please help. Thank you!
>
> Greg.

Dim db as DAO.Database, strSQL as String
Set db = currentDb()
db.Execute("DELETE FROM 260Land WHERE [260ID] = '" & Me.txtDel.Value & "';")

Without bracketing the column name, the '260' prefixes may give you
problems.

No offense, but 260Land is a strange name for a table. What's in it?

Re: Missing Operator syntax error is SQL VB code

am 05.04.2008 18:36:18 von Salad

DFS wrote:

> g_k_harrison@yahoo.com wrote:
>
>>Hi. I have a button - Command9 with the Click event to run this code
>>on a form called frmSelforDel.
>>
>>Dim SQL1 As String
>>DoCmd.SetWarnings False
>>SQL1 = "DELETE FROM 260Land WHERE 260ID = txtDel.Value"
>>
>>On that same form is a text box named txtDel with a set value. 260Land
>>is a table with 260ID as a column.
>>
>>I'm not knowledgeable enough to get the syntax correct on this
>>statement. Please help. Thank you!
>>
>>Greg.
>
>
> Dim db as DAO.Database, strSQL as String
> Set db = currentDb()
> db.Execute("DELETE FROM 260Land WHERE [260ID] = '" & Me.txtDel.Value & "';")
>
> Without bracketing the column name, the '260' prefixes may give you
> problems.
>
> No offense, but 260Land is a strange name for a table. What's in it?
>
>
To the original poster, you need to remember dates are surrounded by #,
strings by quotes, and numbers by themselves

txtDel = "YourName"
? "WHERE [260ID] = '" & txtDel & "';"
WHERE [260ID] = 'YourName';
? "WHERE [260ID] = """ & txtDel & """;"
WHERE [260ID] = "YourName";

txtDel = Date()
? "WHERE [260ID] = #" & txtDel & "#;"
WHERE [260ID] = #4/5/2008#;

txtDel = 123
? "WHERE [260ID] = " & txtDel & ";"
WHERE [260ID] = 123;

IceCube
http://www.youtube.com/watch?v=HzeZhCt5PVA

Re: Missing Operator syntax error is SQL VB code

am 08.04.2008 01:21:35 von g_k_harrison

On Apr 4, 11:05=A0pm, "DFS" wrote:
> g_k_harri...@yahoo.com wrote:
> > Hi. I have a button - Command9 with the Click event to run this code
> > on a form called frmSelforDel.
>
> > Dim SQL1 =A0As String
> > DoCmd.SetWarnings False
> > SQL1 =3D "DELETE FROM 260Land WHERE 260ID =3D txtDel.Value"
>
> > On that same form is a text box named txtDel with a set value. 260Land
> > is a table with 260ID as a column.
>
> > I'm not knowledgeable enough to get the syntax correct on this
> > statement. Please help. Thank you!
>
> > Greg.
>
> Dim db as DAO.Database, strSQL as String
> Set db =3D currentDb()
> db.Execute("DELETE FROM 260Land WHERE [260ID] =3D '" & Me.txtDel.Value & "=
';")
>
> Without bracketing the column name, the '260' prefixes may give you
> problems.
>
> No offense, but 260Land is a strange name for a table. =A0What's in it?

Thanks very much! Yes, the number preceding ID was definitely a
problem. 260Land is a section of a form that's the basis for this
database and covers land cost, surveying insurance, etc... I
appreciate your help greatly!