Expand|Select|Wrap|Line Numbers
- Private Sub Print_Report_Click()
- Dim db As DAO.Database
- Dim rpt As Report
- Dim rst As DAO.Recordset
- Dim fld As DAO.Field
- Dim sSQL As String
- Dim txtbx As Access.TextBox
- Dim lblnew As Access.Label
- Dim lngleft As Long
- Dim lngtop As Long
- sSQL = "SELECT TAG FROM ESGBKR"
- Set db = CurrentDb
- Set rst = db.OpenRecordset(sSQL, dbOpenDynaset)
- Set rpt = CreateReport
- rpt.RecordSource = sSQL
- 'Set columns
- Set lblnew = CreateReportControl(rpt.Name, acLabel, acDetail, , "TAG")
- lngtop = lngtop + 200
- If Not (rst.EOF And rst.BOF) Then
- rst.MoveFirst
- Do Until rst.EOF = True
- For Each fld In rst.Fields
- Set txtbx = CreateReportControl(rpt.Name, acTextBox, acDetail, fld.name, lngleft, lngtop)
- txtbx.SizeToFit
- lngtop = lngtop + 25 + txtbx.Height
- Next fld
- rst.MoveNext
- Loop
- Else
- MsgBox "No Records Available"
- End If
- DoCmd.OpenReport rpt.Name, acViewPreview
- rst.Close
- Set rst = Nothing
- Set db = Nothing
- Set rpt = Nothing
- End Sub
Tag
X4-2A
X4-2B
X4-2C
X4-2D
X4-2E
I get a report that shows a column title "TAG" and then five values below that, each of which is "X4-2A". Any ideas what I have coded incorrectly to not get the correct values?
Thanks much