PC Review


Reply
Thread Tools Rate Thread

quotation marks in vba coce

 
 
=?Utf-8?B?VGVk?=
Guest
Posts: n/a
 
      27th Feb 2006
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

 
Reply With Quote
 
 
 
 
chris.nebinger@gmail.com
Guest
Posts: n/a
 
      27th Feb 2006
I would change the Forms formatting to the following format:

Forms("Tracking Print Filtered By Months").Controls("Months")

Otherwise, I think it's okay, assuming the form is actually open when
you run this code.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGVk?=
Guest
Posts: n/a
 
      27th Feb 2006
i didn't know you could do that, chris, _but_ (here's the but), NO cigar!!!
although hovering over the Forms("Tracking Print Filtered By
Months").Controls("Months") in my code shows it equals fifteeen (15) because
i entered 15 from the dropdown combobox on the (yes it's) open form, the
'strwhere' is not getting resolved. hovering over strwhere is showing a bunch
of quotations marks, literally, '"', what appear to be a pair of single
quotes encapsulating one double quotation mark! i don't know what to make of
that. are you surprised?

"(E-Mail Removed)" wrote:

> I would change the Forms formatting to the following format:
>
> Forms("Tracking Print Filtered By Months").Controls("Months")
>
> Otherwise, I think it's okay, assuming the form is actually open when
> you run this code.
>
>

 
Reply With Quote
 
RD
Guest
Posts: n/a
 
      1st Mar 2006
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


 
Reply With Quote
 
=?Utf-8?B?VGVk?=
Guest
Posts: n/a
 
      1st Mar 2006
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

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My question marks, apostrophies and quotation marks are weird. pj Microsoft Word Document Management 1 10th Jan 2008 10:26 AM
Why do quotation marks change to question marks in e-mails receiv. =?Utf-8?B?SiBIZXJuZG9u?= Microsoft Outlook Discussion 0 30th May 2007 08:01 PM
ASP.net Call Server Side Coce via javascript =?Utf-8?B?QW5kcsOp?= Microsoft ASP .NET 1 13th May 2005 10:32 PM
Punctuation marks and quotation marks 29erKilo Microsoft Word New Users 8 19th Aug 2004 02:35 PM
Re: Coce/VBA vs Macros Rick Brandt Microsoft Access 0 7th Jun 2004 04:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:22 AM.