Hello,
i need to create a report from a form. I found a way to do it in the microsoft site, but no way to have it working. My code is the following:
DoCmd.OpenReport "test4", acViewDesign
Set rpt = Reports![test4]
Set rcset = CodeDb.OpenRecordset(querystring)
rpt.RecordSource = querystring
prevcolwith = 0
lblCol = 0
'creating headers
For i = 0 To rcset.Fields.Count - 1
Set labNew = CreateReportControl(rpt.name, acLabel, acPageHeader, , rcset.Fields(i).name, lblCol)
labNew.SizeToFit
lblCol = lblCol + 600 + labNew.Width
Next
'creating details
lngLeft = 0
lngTop = 0
For i = 0 To rcset.Fields.Count - 1
Set txtNew = CreateReportControl(rpt.name, acTextBox, acDetail, , , lngLeft + 15 + prevColwidth, lngTop)
txtNew.SizeToFit
txtNew.ControlSource = rcset(i).name
prevcolwith = prevcolwith + txtNew.Width
Next
'DoCmd.Save
stDocName = "test4"
DoCmd.OpenReport stDocName, acPreview
Am i missing something?? As it is not working, and it should work!
Thank you
i need to create a report from a form. I found a way to do it in the microsoft site, but no way to have it working. My code is the following:
DoCmd.OpenReport "test4", acViewDesign
Set rpt = Reports![test4]
Set rcset = CodeDb.OpenRecordset(querystring)
rpt.RecordSource = querystring
prevcolwith = 0
lblCol = 0
'creating headers
For i = 0 To rcset.Fields.Count - 1
Set labNew = CreateReportControl(rpt.name, acLabel, acPageHeader, , rcset.Fields(i).name, lblCol)
labNew.SizeToFit
lblCol = lblCol + 600 + labNew.Width
Next
'creating details
lngLeft = 0
lngTop = 0
For i = 0 To rcset.Fields.Count - 1
Set txtNew = CreateReportControl(rpt.name, acTextBox, acDetail, , , lngLeft + 15 + prevColwidth, lngTop)
txtNew.SizeToFit
txtNew.ControlSource = rcset(i).name
prevcolwith = prevcolwith + txtNew.Width
Next
'DoCmd.Save
stDocName = "test4"
DoCmd.OpenReport stDocName, acPreview
Am i missing something?? As it is not working, and it should work!
Thank you