Name from Textbox into query ?

S

SpookiePower

I have a button that, when I click it, runs a query.
I want this query to find a person in a table, from the name in the
textbox.
I'm not sure how to put the textbox into the query, but it must be
something
like this -

SELECT *
FROM customer
WHERE table1.name = (the name in the textbox)

How do I do this ?


www.photo.activewebsite.dk
 
S

SpookiePower

Sorry.

The right query is -

SELECT *
FROM customer
WHERE name = (the name in the textbox)
 
J

John Spencer

SELECT *
FROM customer
WHERE [name] = [Forms]![YourFormName]![YourTextboxName]

Warning "Name" is not a good name for a field or any other object in Access.
Every object in Access has a name and it is possible to introduce confusion
into your application if you use "Name" as the name of an object. Try
changing this to FullName or CustName or ...
 
S

SpookiePower

Thanks a lot.
This was just the right query I was looking for :)

About the names you are mention, I know the problem about it.
It was only to explain my problem in a short turn.
But thanks anyway.

Maybe you can help me again :)

The result from the query is showing in a new window.
I want the result to be showed in some textboxes on my form.
Do you know how I do this ?
 
J

John Spencer

Do you want to change the entire recordset for the form? or do you want to
show these records in a subform on the current form? Or do you want to show
the records in a listbox on your form?
 
S

SpookiePower

I'm not sure how to explain it, but on my form I have both a subform
showing a part
of a customer and some textboxes showing the rest of the customer. Each
time
I click on the little arrow in the bottom of the form, it shows a new
customer on the form.
I have about 500 customers, so I dont want to click 300 times if I want
to get to number
300. Thats why I asked for the query to find the exact customer. But
this customer is showing up in a new window that looks like a table.
And I'm afraid the user will get confused
about this new "table-window", so I want the customer to be displayed
in the subform+textboxes thats placed on the form, insted of in a
pop-up-table-window.

Thanks in advance
 
J

John Spencer

Ahh! Now we know what you are trying to do.

Your button code should read something like the following.

'=======================================
Private Sub Command36_Click()
Dim strFind as String

On Error GoTo ERROR_Command36_Click
strFind = " [name] = " & chr(34) & Me.[YourTextboxName] & Chr(34)
With Me.RecordsetClone
.FindFirst strFind
If .NoMatch = False Then
Me.Bookmark = .Bookmark
Else
Beep
End If
End with

EXIT_Command36_Click:
On Error GoTo 0
Exit Sub

ERROR_Command36_Click:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
End Sub
'=======================================
 
S

SpookiePower

Thanks a lot.

This code seems a little confusing to me, but I'll try to decode it.
I'm a little used to VBA, but this code is not what I'm used to.
Hope I can get it to work.
 
Top