Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > editing a database with textboxes


Reply
 
Thread Tools Display Modes
  #1  
Old 05-03-2004, 07:37 AM
davieboy_xr davieboy_xr is offline
Centurion
 
Join Date: Nov 2003
Location: uk
Posts: 174
Default editing a database with textboxes


hi.. got a bit of a bit problem editing records from text boxes.

On my form i have about 10 editable fields. When a click is detected in a textbox ,a separte form loads with a text box which displays the previous information , so that the user can edit the record.

my question is..
How can i detect which text box is selected so that i can update the relevant record in the database?
Thanks dave
Reply With Quote
  #2  
Old 05-03-2004, 08:09 AM
LaVolpe's Avatar
LaVolpe LaVolpe is offline
Ultimate Contributor

* Expert *
 
Join Date: Apr 2004
Location: Illinois
Posts: 2,499
Default

One easy solution: Try setting a form-wide variable as an object, i.e., Private LastText As TextBox
Then for each of your text box's GotFocus event, set LastText = thatTextbox.
Code:
Private LastTextBox As TextBox Private Sub Text1_GotFocus() Set LastTextBox = Text1 End Sub
__________________
Insomnia is a simple byproduct of "it can't be done" {Window Shaper}
Reply With Quote
  #3  
Old 05-03-2004, 08:22 AM
davieboy_xr davieboy_xr is offline
Centurion
 
Join Date: Nov 2003
Location: uk
Posts: 174
Default

thanks for the reply...bit lost now.. would i put this in the first form, not the editing form
Reply With Quote
  #4  
Old 05-03-2004, 08:35 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

If you have three text boxes on your form, in each one, you would assign this Got_focus event. So then, this private variable (within the scope of the form) would update accordingly. Interesting idea LaVolpe .
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #5  
Old 05-03-2004, 08:50 AM
davieboy_xr davieboy_xr is offline
Centurion
 
Join Date: Nov 2003
Location: uk
Posts: 174
Default

Thanks fellas ... ive declared it a public variable so now i can get the value in another form

So now what ill do is open up a connection to the database in the save button and then update the relevant record.
so then i have

Code:
rs!myrecordset = form1.LastTextBox rs.update rs.save rs.close con.close
Does that seems like the right way to do it?
Reply With Quote
  #6  
Old 05-03-2004, 08:51 AM
LaVolpe's Avatar
LaVolpe LaVolpe is offline
Ultimate Contributor

* Expert *
 
Join Date: Apr 2004
Location: Illinois
Posts: 2,499
Default

Quote:
How can i detect which text box is selected so that i can update the relevant record in the database?
Quote:
would i put this in the first form, not the editing form
The answer is directly related to your first question.
The Private LastTextBox As TextBox statement goes near the top of the form that this code goes into.
__________________
Insomnia is a simple byproduct of "it can't be done" {Window Shaper}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Files linked to Database Mat_J General 6 06-05-2003 05:31 PM
Database to Database lothos12345 Database and Reporting 1 03-03-2003 06:52 PM
Attaching textboxes to an accesss database Doubs Database and Reporting 10 01-29-2003 10:30 AM
Still write to database problem cballe Database and Reporting 0 08-08-2002 05:22 AM
Database problem for database Guru`s cballe Database and Reporting 5 08-08-2002 03:24 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->