PDA

View Full Version : Solved: Edit Access Table Info



stapuff
03-10-2008, 05:25 AM
I ran into an error I do not seem to understand:


This works..........


Private Sub UserForm_Initialize()
Set rst = New ADODB.Recordset
Set cn = New ADODB.Connection

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=F:\Open Projects\Sunkist.mdb;"
.Open
End With

rst.Open "Select ID From XXXExp_Date", cn

ComboBox1.List = Application.WorksheetFunction.Transpose(rst.GetRows)

End Sub


Error on the **** line below is -Item can not be found in the collection corresponding to the request name or ordinal.


Private Sub ComboBox1_Change()
Dim strSQL As String
Dim I As Long
Set rst = New ADODB.Recordset
strSQL = "SELECT * FROM XXXExp_Date WHERE ID =" & ComboBox1.Value

rst.Open strSQL, cn

For I = 1 To 5
**** Me.Controls("TextBox" & I) = rst.Fields("Fields" & I)
Next I

End Sub



I do not uderstand the error since I am selecting the record from the combobox. ID is an auto number.

Any help would be appreciated.

Kurt

Bob Phillips
03-10-2008, 06:04 AM
Shouldn't it be



rst.Fields(I)

stapuff
03-10-2008, 06:47 AM
Thank You