How to assign values to the text fields?

G

Guest

Douglas, I followed your method of passing values from a form to report and
wrote code something like this-

in cmdGenerateReport_Click event in form frmReports --
Dim strArgs As String
strArgs = dtFromDate & ";" & dtToDate
DoCmd.OpenReport "rptDailyAttendance_Brief2",
acViewPreview, , "Attendance_Date between #" & dtFromDate & "# and #" &
dtToDate & "#", , strArgs

in Report_Open event --
Dim varValues As Variant
Dim dtFromDate As Date
Dim dtToDate As Date
If IsNull(Me.OpenArgs) = False Then
varValues = Split(Me.OpenArgs, ";")
dtFromDate = varValues(0)
dtToDate = varValues(1)
Me.txtFromDate = dtFromDate ''' getting error here
Me.txtToDate = dtToDate
End If

txtFromDate and txtToDate are unbound fields in the report

I am getting an error at Me.txtFromDate=....The error says -" You can't
assign a value to this object."
I am able to retrieve the values of the FromDate and ToDate from the form
frmReports into the report_open event but I am unable to assing these values
to the txtFromDate and txtToDate text fields of the report.How do I do this?
 
G

Guest

Yes Douglas, the two controls are text boxes.
Am I committing a basic mistake else where?Does the data types have
something to do with this?

-------------
Anand Vaidya
I''m here to know.


Douglas J Steele said:
You sure they're text boxes and not labels?
 
G

Guest

Douglas, I commented the whole code in the Report_Open event and tried to
test this-
me.txtFromDate="Hello"
I am getting the same error.
-------------
Anand Vaidya
I''m here to know.


Douglas J Steele said:
You sure they're text boxes and not labels?
 
D

Douglas J Steele

Anything else named txtFromDate in your form?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Anand Vaidya said:
Douglas, I commented the whole code in the Report_Open event and tried to
test this-
me.txtFromDate="Hello"
I am getting the same error.
 
G

Guest

No Douglas,there's only one txtFromDate.

I even tried adding a new text control on to the form and assigning some
value to it as - me.text44="Helloo", it gives the same error.(can't assing
value to this object)
 
D

Douglas J Steele

Something sounds very wrong.

If you create a new database and try there, does it work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top