Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Use variable in sql

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Use variable in sql
Alex 12.07.2006 00:25:02
If I use the code below, records are deleted from my table if I replace
tblModel with the name of a real table. However, I need to use a table
variable instead. I've set it with tblModel, which gives the correct table
name, but it doesn't work within my RunSQL. Any ideas how I can use a table
variable? Thanks much.


Private Sub Command4_Click


tblModel = "Export" & [Forms]![Export_Ref_Parts]![ModelToImport]

DoCmd.RunSQL "Delete tblModel WHERE ((([Part#]) Is Null));"


End Sub
Re: Use variable in sql
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 12.07.2006 00:32:48
DoCmd.RunSQL "Delete " & tblModel & " WHERE ((([Part#]) Is Null));"


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Alex" <Alex[ at ]discussions.microsoft.com> wrote in message
news:A1ED57ED-B591-4BB9-813F-53996C118E53[ at ]microsoft.com...
[Quoted Text]
> If I use the code below, records are deleted from my table if I replace
> tblModel with the name of a real table. However, I need to use a table
> variable instead. I've set it with tblModel, which gives the correct
> table
> name, but it doesn't work within my RunSQL. Any ideas how I can use a
> table
> variable? Thanks much.
>
>
> Private Sub Command4_Click
>
>
> tblModel = "Export" & [Forms]![Export_Ref_Parts]![ModelToImport]
>
> DoCmd.RunSQL "Delete tblModel WHERE ((([Part#]) Is Null));"
>
>
> End Sub


Re: Use variable in sql
"david epsom dot com dot au" <david[ at ]epsomdotcomdotau> 31.07.2006 11:32:29
Waiting for trouble using # in a field or table name, because # is also
sometimes used as an alias for . dot. Expect trouble just when you least
expect it.

(david)

"Alex" <Alex[ at ]discussions.microsoft.com> wrote in message
news:A1ED57ED-B591-4BB9-813F-53996C118E53[ at ]microsoft.com...
[Quoted Text]
> If I use the code below, records are deleted from my table if I replace
> tblModel with the name of a real table. However, I need to use a table
> variable instead. I've set it with tblModel, which gives the correct
> table
> name, but it doesn't work within my RunSQL. Any ideas how I can use a
> table
> variable? Thanks much.
>
>
> Private Sub Command4_Click
>
>
> tblModel = "Export" & [Forms]![Export_Ref_Parts]![ModelToImport]
>
> DoCmd.RunSQL "Delete tblModel WHERE ((([Part#]) Is Null));"
>
>
> End Sub


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net