Solved

simple or not?

Posted on 2001-06-19
5
130 Views
Last Modified: 2010-05-02
Hi!

I have a lot of textbox controls on form and their names are written in DB table_1 in column fields like text1, text2, text3?
When I want to save user?s input I want to generate sql (INSERT INTO?)  so I read all from table_1 and replace in sql sentence with theirs value.

I tried like this

dim usr_input as textbox
usr_input = recordset!fields
msgbox usr_input.text

text1.text value is TEST
and TEST should be returned
0
Comment
Question by:Mitja100
  • 3
5 Comments
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6206092
You can get the field names from the recordset(something like this...

sqlclause = "SELECT * FROM mytable"
Set Rs = DBConn.Execute(sqlclause)
For Each Field In Rs.Fields
 MsgBox Field.Name
Next


Is this what you're after?
0
 
LVL 5

Accepted Solution

by:
GeoffKell earned 100 total points
ID: 6206158
I thought you wanted the column name to be the textbox name. If so try

sqlclause = "SELECT * FROM mytable"
Set Rs = DBConn.Execute(sqlclause)
For Each Field In Rs.Fields
  MsgBox Me.Controls(Field.Name).Text
Next

Use the column name (Field.Name) as a lookup into the controls on the form.

Regards
GK
0
 

Author Comment

by:Mitja100
ID: 6206160
nigelrowe:
Accessing DB and reading data is not problem.
Actually in first DB I have list of names of all textboxes (text1, text2, text3), and I want to write values (user will input them) of this textboxes in second DB (value_of_text1, value_of_text3, value_of_text3).

Mitja
0
 

Author Comment

by:Mitja100
ID: 6206288
nigelrowe:
Accessing DB and reading data is not problem.
Actually in first DB I have list of names of all textboxes (text1, text2, text3), and I want to write values (user will input them) of this textboxes in second DB (value_of_text1, value_of_text3, value_of_text3).

Mitja
0
 

Author Comment

by:Mitja100
ID: 6206298
Thanx GeoffKell!

Me.Controls(Field.Name).Text

This is exactly what I was looking for.


Mitja
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now