p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 9th, 2009, 01:06 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old January 9th, 2009, 06:49 AM
Friend of Wrox
Points: 6,324, Level: 33
Points: 6,324, Level: 33 Points: 6,324, Level: 33 Points: 6,324, Level: 33
Activity: 69%
Activity: 69% Activity: 69% Activity: 69%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 1,947
Thanks: 5
Thanked 30 Times in 29 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.
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old January 11th, 2009, 07:46 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 06:11 AM
Get Field Names fizzerchris Classic ASP Databases 1 February 25th, 2006 04:06 AM
Problem with variable names shenku Javascript 2 May 6th, 2005 03:46 PM



All times are GMT -4. The time now is 09:50 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc