PDA

View Full Version : Copy data from table to subform



Trevor
04-28-2008, 02:30 PM
I am getting an error: object variable or withblock not set and my Do until .EOF line is highlited. I am trying to pull data from a table then copy it to a subform, and the form I'm opening with the code does open but nothing copies to it, I get the error message above.


Private Sub Command10_Click()
Dim qryDB As DAO.Database
Dim loRst As DAO.Recordset
stDocName = "SU-IL"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Set loRst1 = CurrentDb.OpenRecordset("SELECT * FROM [Su-ILT-Sub] WHERE" _
& " [IDNumber]= '" & Forms![Su-ILQ]![IDNumber] & "';")
With loRst
Do Until .EOF
For Each Control In Forms![Su-IL]![InvoiceSubform].Controls
If Control.ControlType = acTextBox And Control.Name = "Billing For" Then
Forms![Su-IL]![InvoiceSubform]![Billing For] = Forms![Su-IL]![InvoiceSubform]![Billing For] & .Fields("Billing For")
.MoveNext
End If
Next
Loop
End With
Set loRst = Nothing
loRst.Close
End Sub