non programmer question for capturing of input in a form

T

tealeaf

lets say i have a table with only 2 fields(label and id)
with info in them.
i have a form with just a textbox whereby a user inputs a
text and presses enter.

i need that captured input to search the 'label' field in
that table for an exact match, followed by deleting the
entire row which the exact match recides in.
(eg user inputs "ab", the table has a row where 'label'
is "ab", and corresponding 'id' is 12. both of them(ab &
12) would be wiped out of the table.

Q1) how do i capture the users input?(i do not wish to
store that in another table as it would be redundant
later)
Q2) how do i use that captured input as a selection for a
delete query?

i have zero programming knowledge and the only access
knowledge i have are those in teach yourself access or
dummies books so it would be best if the solutions were
non code. if it has to be code, try to make it simple pls.
if possible, pls send the solution to my email.
many thanks in advance.
 
S

Stewart Tanner

firstly a label is a type of control on a form so it is not a good
fieldname.

Where did the ID value of 12 come from?

Unfortunately code is the easiest solution.

in the afterupdate event of the textbox
if not isnull(me.textbox) then
docmd.runsql "delete * from tablename where ID = 12 and label =" &
chr(34) & me.textbox & chr(34)
End If
 
T

tealeaf

hmm... maybe i should explain it in more detail.
i have 1 table named; 'bookout'.
it has 2 fields named; 'pub' and 'id'.
the values for all rows in the 2 fields could be anything
but defintely is manually inputted text of up to 8
characters max(not a calculation nor expression).

in a form, the user keys in something & presses enter. the
user input will be compared with the all entries of
the 'pub' field of that table 'bookout'. once there is a
exact match from the user input with the value in the pub
field. that row(record) is deleted(regardless of the value
in the id field).

from my understanding after what u've mentioned is that i
have to use code in the afterupdate event of the textbox.
so how do i code the above mentioned?
 
S

Stewart Tanner

Hi TeaLeaf,

in design mode of your form click on the text box.
in the properties section go to events
in the afterupdate event click and then click on the little grey button with
the three dots to the right. Select code.

in the event procedure that should now be open put the following (replacing
Textbox with the name of the text box that you are using)

if not isnull(me.textbox) then
docmd.setwarnings false
docmd.runsql "delete * from bookout where pub =" & chr(34) &
me.textbox & chr(34)
docmd.setwarnings true
End If
 
G

Guest

YOU ARE MY SAVIOR!!!! thanks u very much
-----Original Message-----
Hi TeaLeaf,

in design mode of your form click on the text box.
in the properties section go to events
in the afterupdate event click and then click on the little grey button with
the three dots to the right. Select code.

in the event procedure that should now be open put the following (replacing
Textbox with the name of the text box that you are using)

if not isnull(me.textbox) then
docmd.setwarnings false
docmd.runsql "delete * from bookout where pub =" & chr(34) &
me.textbox & chr(34)
docmd.setwarnings true
End If






.
 

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