Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2009, 02:06 AM
Registered User
 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default variable field names

hi!
pls help me how to do this?

my form has two combo box, cboLoanType, cboField and a text box, txtAmount

- users click cboLoanType(which correspond to names of tables of loan e.g. "emergency loan", "appliance loan", "financing loan" etc.

- on click event of cboLoanType this is what happened:

Dim rsDBName As ADODB.Recordset
Dim txtFieldName() As String

Private Sub cboLoanType_Click()
Set rsDBName = New ADODB.Recordset
Dim txtDBname As String
Dim i As Integer

'retrieve the name of the table and open it
txtDBname = "select * from " & cboLoanType.Text
rsDBName.Open txtDBname, cnn, adOpenStatic, adLockOptimistic

' then loop to get the field names and add to cboField items
With cboField
.Clear
For i = 1 To rsDBName.Fields.Count - 1
ReDim txtFieldName(i)
txtFieldName(i) = rsDBName.Fields.Item(i).Name
.AddItem "" & txtFieldName(i)
Next i
End With
End Sub

clicking cboField gives users list of fields to choose where to post payment

later on the save button this is what i can't figure out how to do it.
i'm trying to save now the content of text box(txtAmount) to the field corresponding to the value of cboField in the table which cboLoanType combo box holds.

any help would be appreciated very very much. thank you
 
Old January 9th, 2009, 07:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

I don't remember if you can save the value the same way you recover it (RS.fields.item(name).value)... but if not, you can build a simple SQL to store the value, something like: UPDATE tablename SET fieldname = value. You have all the info for this...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old January 11th, 2009, 08:46 PM
Registered User
 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
Hi there..

I don't remember if you can save the value the same way you recover it (RS.fields.item(name).value)... but if not, you can build a simple SQL to store the value, something like: UPDATE tablename SET fieldname = value. You have all the info for this...

thanks bro for your time spent. God bless you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
generate variable names dinamycally gcorcuera Classic ASP Basics 7 May 21st, 2007 09:53 AM
XSLT For Each - Field Names lahatfield XSLT 6 May 15th, 2007 06:33 AM
dynamic variable/object names TheBFJ Excel VBA 2 November 13th, 2006 07:11 AM
Get Field Names fizzerchris Classic ASP Databases 1 February 25th, 2006 05:06 AM
Problem with variable names shenku Javascript 2 May 6th, 2005 03:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.