Hi RD,
I'm not bothered at all by the quality and tone of your feedback. I really
appreciated it (given my VBA newbie status, it almost boggles my mind that I
ever get anything I write to work at all....but it does)
I will try to make a point of following some of the points/tips you raised
in yours.
With regards.
Ted
"RD" wrote:
> Hi Ted,
>
> Please take this in the spirit intended: this code is a mess. It's extremely
> hard to read and there are several problems with it. The one to which you refer
> is likely caused by the field "[FollowUp]" referred to in this section:
>
> >strWhere = Forms![Tracking Print Filtered By Months]![Months] & _
> > [FollowUp] & "Between #" & Forms![Tracking Print Filtered By
> >Months]![StartDate] & _
>
> You didn't qualify it like you did the other fields.
>
> A couple of other things:
> 1. You don't need the "= True" with the IsNull function. You can simply say:
> If IsNull(Me.FieldName) Then
> Do something
> End If
>
> 2. You Dim response2 as Integer and set it equal to a message box but you don't
> return the value of the message box. If you don't really need that value the way
> to create a message box is:
> If condition Then
> MsgBox prompt, style, title, etc. 'note no parentheses
> End If
>
> 3. Your naming of reports and forms is going to prove to be a real PITA. You can
> set form and report Caption properties to be something user friendly but the
> actual names that you use in programming should be concise while still
> descriptive AND ... contain no spaces!
>
> All this being said, I C&Pd your code into a form module and, after several
> minutes of cleaning it up, it did compile. Surprised me.
>
> I hope this has been of some help,
> RD
>
>
> On Mon, 27 Feb 2006 10:51:31 -0800, Ted <(E-Mail Removed)> wrote:
>
> >in my code below (which is behind a 'print report' button on a form which
> >takes the values 'months', 'start date' and 'stop date' that act to delimit
> >the range of this report, when i click report, the message seems to get
> >printed just fine, but then it is followed by this access message:
> >
> >"Microsoft Access can't find the field 'Forms' referred to in your
> >expression."
> >
> >i think i know the part of the code it's talking about, but what would it
> >take to put it to sleep?
> >
> >any insights'd be really welcome.
> >
> >-ted
> >
> >code:
> >
> >Private Sub PrintReport_Click()
> >On Error GoTo Err_PrintReport_Click
> > Dim response1 As Integer
> > Dim stDocName As String
> > Dim strWhere As String
> > Dim response2 As Integer
> >
> > If IsNull(Me.Months) = True Or IsNull(Me.StartDate) = True Or
> >Me.StopDate = #1/1/1899# Then
> > response2 = MsgBox("You have entered at least one invalid date. Review
> >and correct your entries.", vbOKOnly + vbCritical, "Error")
> > GoTo Line1
> > Else: response1 = MsgBox( _
> > "Your specifications call for printing a report for patients at their "
> >& Forms![Tracking Print Filtered By Months]![Months] & _
> > " months visit which spans the dates " & Forms![Tracking Print Filtered
> >By Months]![StartDate] & " and " _
> > & Forms![Tracking Print Filtered By Months]![StopDate] _
> > & ". If this is correct, click 'OK' to proceed or else click 'Cancel'
> >and re-enter them.", vbOKCancel + vbInformation, "Attention User")
> >
> > If response1 = 1 Then
> > stDocName = "Selected Months Patients on Follow-Up"
> > strWhere = Forms![Tracking Print Filtered By Months]![Months] & _
> > [FollowUp] & "Between #" & Forms![Tracking Print Filtered By
> >Months]![StartDate] & _
> > "# And #" & Forms![Tracking Print Filtered By Months]![StopDate] & "#"
> >
> > DoCmd.OpenReport stDocName, acViewNormal, , strWhere
> >
> > ElseIf response1 = 2 Then GoTo Line1
> > End If
> >Exit_PrintReport_Click:
> > Exit Sub
> >
> >
> >Err_PrintReport_Click:
> > MsgBox Err.description
> > Resume Exit_PrintReport_Click
> >
> > End If
> >
> >Line1:
> >End Sub
>
>
|