Hello,
My report is already created, but I need to create the textboxes by code 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! it won't work, and all the time it shows a -1 as a unique value. The labels are created great, but not the text boxes...
Also i would need to delete the text boxes in case they exist, and don't know how...
Thank you
My report is already created, but I need to create the textboxes by code 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! it won't work, and all the time it shows a -1 as a unique value. The labels are created great, but not the text boxes...
Also i would need to delete the text boxes in case they exist, and don't know how...
Thank you