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
|