Hi all,
Hopefully someone can help me with this piece of code.
I have six textbox controls (txtMVL1 - txtMVL6) and wan't to populate them from a recordset.
Here is the code I wrote to loop through the recordset -
I am really not sure how to deal with populating each control. I did try declaring the control as a string eg. "txtMVL" & i with i incrementing by one in the loop - but this does not seem to work - I think perhaps syntax related.
eg.
Can anyone advise me how to approach this problem?
Thanks and regards,
Rob
Hopefully someone can help me with this piece of code.
I have six textbox controls (txtMVL1 - txtMVL6) and wan't to populate them from a recordset.
Here is the code I wrote to loop through the recordset -
Code:
'Populate the MVL details from tblMVL
strSQL = "SELECT * FROM tblMVL WHERE CUSTOMER_NO =" & CusNo & ";"
Set ADOrs = New ADODB.Recordset
ADOrs.ActiveConnection = CurrentProject.Connection
ADOrs.Open strSQL, , adOpenKeyset, adLockOptimistic
With ADOrs
If .BOF Or .EOF Then
.Close
Else
Do Until .EOF
'Need help here
.MoveNext
Loop
End If
.Close
End With
Set ADOrs = Nothing
I am really not sure how to deal with populating each control. I did try declaring the control as a string eg. "txtMVL" & i with i incrementing by one in the loop - but this does not seem to work - I think perhaps syntax related.
eg.
Code:
Dim strControl As String
Dim i As Integer
i = 0
.
.
.
Do Until .EOF
strControl = "txtMVL" & i
Forms!MyForm!strControl.Value = .fields("MVL")
i = i + 1
.MoveNext
Loop
Can anyone advise me how to approach this problem?
Thanks and regards,
Rob