Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Error on opening report from form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NeoFax - 13 Mar 2008 19:18 GMT
Below is the code I am using to open a report based on criteria from
three comboboxes.  The problem is that the report errors as the
WhereCondition is wrong.  Here is the code:

Private Sub btnJC_OpenFull_Click()
On Error GoTo Err_btnJC_OpenFull_Click
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(cmbHelo) Then
 stLinkCriteria = "[Stage#]" & "=" & """ & cmbStage & """ &
"[Responsibility]" & "=" & """ & cmbResp & """
ElseIf IsNull(cmbStage) Then
 stLinkCriteria = "[HELO#]" & "=" & """&cmbHelo&""" &
"[Responsibility]" & "=" & """ & cmbResp & """
ElseIf IsNull(cmbResp) Then
 stLinkCriteria = "[HELO#]" & "=" & """&cmbHelo&""" & "[Stage#]" &
"=" & """ & cmbStage & """
Else
 stLinkCriteria = "[HELO#]" & "=" & """ & cmbHelo & """ & "[Stage#]"
& "=" & """ & cmbStage & """ & "[Responsibility]" & "=" & """ &
cmbResp & """
End If

stDocName = "rptJC_OpenFull"

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_btnJC_OpenFull_Click:
   Exit Sub

Err_btnJC_OpenFull_Click:
   MsgBox Err.DESCRIPTION
   Resume Exit_btnJC_OpenFull_Click

End Sub

Any help would be appreciated.  Thanks!

Terry
ruralguy - 13 Mar 2008 19:52 GMT
Use either a Debug.Print, MsgBox or single step to see what you are actually
putting in your WhereCondition string.

>Below is the code I am using to open a report based on criteria from
>three comboboxes.  The problem is that the report errors as the
[quoted text clipped - 36 lines]
>
>Terry

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

NeoFax - 13 Mar 2008 20:08 GMT
On Mar 13, 2:52 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
wrote:
> Use either a Debug.Print, MsgBox or single step to see what you are actually
> putting in your WhereCondition string.
[quoted text clipped - 47 lines]
>
> - Show quoted text -

Here is what I get when I click the button:

"[HELO#]=14704 And [Stage #]=" & cmbStage & " And [Lead]=" & cmbResp &
""

This is what it should look like:

"[HELO#]=14704 And [Stage #]="4FL" And [Lead]="Flightline""

The problem is the triple quotation marks.  How do I get quotation
marks to show up in VBA?
NeoFax - 13 Mar 2008 20:15 GMT
> On Mar 13, 2:52 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
> wrote:
[quoted text clipped - 64 lines]
>
> - Show quoted text -

I figured it out.  I just had to change the quotes to triple for begin
and quadruple for end.  Now to figure out how to build the
strlinkcriteria if they don't select certain data in the comboboxes.
ruralguy - 13 Mar 2008 20:30 GMT
You are on your way NeoFax. Excellent!

>> On Mar 13, 2:52 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
>> wrote:
[quoted text clipped - 5 lines]
>and quadruple for end.  Now to figure out how to build the
>strlinkcriteria if they don't select certain data in the comboboxes.

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.