Looking up from a text box

G

Guest

I'm having a problem with some VB and SQL in my db. I am trying to run a
query on questions by using a text box as the criteria. Here's the code I
was using:


Dim listname As String
Dim mcroname As String
Dim refreshname As String


listname = "Text1"
mcroname = "requery"
refreshname = "List23"
DoCmd.RunSQL "Delete From [Temp Actions]"
DoCmd.RunSQL "INSERT INTO [Temp Actions] ( [Action] )SELECT
Actions.Action FROM Actions WHERE (((Actions.[Project Name]) = listname))"
DoCmd.RunMacro mcroname
DoCmd.RunMacro refreshname

I'm trying to take all questions with the Project Name for the action is the
same as what is contained in Text1. When i run this, it brings an imput box
asking for the value in "listname" rather than looking it up. Any ideas on
what I'm doing wrong?

Thanks
 
P

Pieter Wijnen

quotes, quotes + variables

WHERE Actions.[Project Name] ='" & listname & "'"

Pieter


Dave said:
I'm having a problem with some VB and SQL in my db. I am trying to run a
query on questions by using a text box as the criteria. Here's the code I
was using:


Dim listname As String
Dim mcroname As String
Dim refreshname As String


listname = "Text1"
mcroname = "requery"
refreshname = "List23"
DoCmd.RunSQL "Delete From [Temp Actions]"
DoCmd.RunSQL "INSERT INTO [Temp Actions] ( [Action] )SELECT
Actions.Action FROM Actions WHERE (((Actions.[Project Name]) = listname))"
DoCmd.RunMacro mcroname
DoCmd.RunMacro refreshname

I'm trying to take all questions with the Project Name for the action is
the
same as what is contained in Text1. When i run this, it brings an imput
box
asking for the value in "listname" rather than looking it up. Any ideas
on
what I'm doing wrong?

Thanks
 
G

Guest

That doesn't seem to work...when I changed my code to that and ran the
update, it didn't find any entries that mached, when there should have been
three. I entered new test data and found the same thing to be true.

Pieter Wijnen said:
quotes, quotes + variables

WHERE Actions.[Project Name] ='" & listname & "'"

Pieter


Dave said:
I'm having a problem with some VB and SQL in my db. I am trying to run a
query on questions by using a text box as the criteria. Here's the code I
was using:


Dim listname As String
Dim mcroname As String
Dim refreshname As String


listname = "Text1"
mcroname = "requery"
refreshname = "List23"
DoCmd.RunSQL "Delete From [Temp Actions]"
DoCmd.RunSQL "INSERT INTO [Temp Actions] ( [Action] )SELECT
Actions.Action FROM Actions WHERE (((Actions.[Project Name]) = listname))"
DoCmd.RunMacro mcroname
DoCmd.RunMacro refreshname

I'm trying to take all questions with the Project Name for the action is
the
same as what is contained in Text1. When i run this, it brings an imput
box
asking for the value in "listname" rather than looking it up. Any ideas
on
what I'm doing wrong?

Thanks

--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 4388 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
 
D

Douglas J. Steele

You're missing a space between ) and SELECT: that could be causing problems.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Dave said:
That doesn't seem to work...when I changed my code to that and ran the
update, it didn't find any entries that mached, when there should have
been
three. I entered new test data and found the same thing to be true.

Pieter Wijnen said:
quotes, quotes + variables

WHERE Actions.[Project Name] ='" & listname & "'"

Pieter


Dave said:
I'm having a problem with some VB and SQL in my db. I am trying to run
a
query on questions by using a text box as the criteria. Here's the
code I
was using:


Dim listname As String
Dim mcroname As String
Dim refreshname As String


listname = "Text1"
mcroname = "requery"
refreshname = "List23"
DoCmd.RunSQL "Delete From [Temp Actions]"
DoCmd.RunSQL "INSERT INTO [Temp Actions] ( [Action] )SELECT
Actions.Action FROM Actions WHERE (((Actions.[Project Name]) =
listname))"
DoCmd.RunMacro mcroname
DoCmd.RunMacro refreshname

I'm trying to take all questions with the Project Name for the action
is
the
same as what is contained in Text1. When i run this, it brings an
imput
box
asking for the value in "listname" rather than looking it up. Any
ideas
on
what I'm doing wrong?

Thanks

--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 4388 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top