Results 1 to 9 of 9

Thread: [RESOLVED] Write textbox value to field in table with VBA coding

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    367

    Re: Write textbox value to field in table with VBA coding

    Well, I guess it's just my vb 6.0 coding that's got me thinking the way I first said.

    What is fldfoo? is that supposed to be the unique identifier so it knows which record to point to?

    How would I right the sql statement if I wanted to updated multiple fields/textboxes the same way?

    And, here's more info, just in case it clears some of it up. I have a subform pointing to the same table. On the subform I have a textbox linked to the primary key just so I can see which record it's currently on. As soon as the user types info into the subform the textbox linked to the primary key populates with 68 for example letting me know it's on the new record 68.

    Now, if those earlier text boxes on the main form are not bound when they hit the command button wouldn't it put the values of those unbound text boxes into the record 68 since it's currently pointing there as they entered the new data in the subform?

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Write textbox value to field in table with VBA coding

    Quote Originally Posted by lilmark
    How would I right the sql statement if I wanted to updated multiple fields/textboxes the same way?
    Either multiple SQL commands or make the Where clause include all the records you want to update. Which way you do it depends on your data and the update criteria.

    VB Code:
    1. ... Where fldIndex = 68 ...
    would update one record.
    VB Code:
    1. ... Where fldFoo = 'Administrator' ...
    could update many records.

    As far as many fields:

    VB Code:
    1. strSQL = "UPDATE tblInfo SET fldName = '" & Me.TextBox1.Text & "', fld2Name = '" & Me.TextBox2.Text & "' ... WHERE fldFoo = somevalue"
    And, here's more info, just in case it clears some of it up. I have a subform pointing to the same table. On the subform I have a textbox linked to the primary key just so I can see which record it's currently on. As soon as the user types info into the subform the textbox linked to the primary key populates with 68 for example letting me know it's on the new record 68.

    Now, if those earlier text boxes on the main form are not bound when they hit the command button wouldn't it put the values of those unbound text boxes into the record 68 since it's currently pointing there as they entered the new data in the subform?
    No, the SQL statement isn't looking at the subform to figure out which records to update, it's looking at the Where clause.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width