Use an (un)bound textbox to update the value of a table's field

Never Hide

Registered User.
Local time
Today, 23:11
Joined
Dec 22, 2011
Messages
96
Hello everyone,
I've tried searching about my poblem but I can't find somethig about it (pretty sure it has to do with the words I'm using to search but anyway...)

I have a table Names: (id, Name, Nick_Name)
I have a form with 2 comboxes both based on that table. 1st combobox lets you browse based on the Name and 2nd one lets you browse based on the Nick_Name. When you make a selection in Name_combobox, Nick_Name_combobox displays the responding nickname and vise versa.

I want to add a textbox which will allow you to (once you have made a selection) change the Nick_Name for the selected entry.
So an example would be

Name_combobox : John
Nick_Name : Big John
New_Nick_textbox : Little John

New_Nicj_textbox is the textbox at hand :)
In this textbox you type "Little John", press a button and "Little John" will take the place of "Big John" in the Nick_Name Field

EDIT-I forgot to mention thateverything in the form, including the form, is unbound (don't know if that'll help you in any way but thought I should mention it :D
 
Last edited:
After some messing around and trial and error I figured it out :)
At the command button, in the "Click" event I used this code
Code:
    Me.new_Nick_Name_txtb.SetFocus
    strSQL = "UPDATE Names SET Names.Nick_Name = " & _
             "Replace([Nick_Name],'" & Me.Nick_Name_combob.Column(1) & "','" & Me.new_Nick_Name_txtb.Text & "');"
    DoCmd.RunSQL (strSQL)
I'd like to ask if there is a way to stop the update query warning window fom showing up
 
Last edited:

Users who are viewing this thread

Back
Top Bottom