Passing Parameters to Access Report from VB.Net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elle Short via .NET 247

    Passing Parameters to Access Report from VB.Net

    Hello All, any help would be appreciated:

    I am trying to pass a parameter to an Access Report. Just runningthe report from .net with no parameter in my access query and nowhereconditio n clause in my .net ...report prints correctly.

    As soon as I add the parameter to my Access query, and thewhereconditi on to my .net....the .Net form pop's up a parameterbox for the user to enter the parameter. That's not what I want,I want to pass the text field automatically. I'm thinking it'sa syntax thing, but am having no luck finding an example:

    Private Sub Button1_Click(B yVal sender As System.Object,B yVal e As System.EventArg s) Handles Button1.Click
    Me.txtUKey.Text = 112 'just a test number to pass
    Dim oAccess As Access.Applicat ion
    oAccess = New Access.Applicat ionClass()
    oAccess.OpenCur rentDatabase(fi lepath:="c:\Ine tpub\wwwroot\tr ibalastprgs\Ast PrgData.mdb", exclusive:=Fals e)
    oAccess.DoCmd.O penReport(Repor tName:="HCSPRpt ",View:=Access. AcView.acViewNo rmal, _
    wherecondition: ="[ukey]=" & Me.txtUKey.Text )



    Thanks!! I appreciate any help you send my way. Elle
    --------------------------------
    From: Elle Short

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>TMliX8gi7kK smye541escQ==</Id>
  • spamfurnace

    #2
    Re: Passing Parameters to Access Report from VB.Net

    Gidday

    Ive never done it so im sure but I remember when i was playing around with
    AccessDb's that whenever you pass text to a where clause in the DLookup's
    method etc you had to go [Field]='" & sometext & "'".

    Note the additional ' single quote before and after the " double quotes.
    Access is a bit snotty about things like that. Sql Server seems a little
    more intelligent in that respect.

    Even if the value of your key text is numeric you are passing text. So try
    the above or cast to the appropriate non text data type if its not text.
    hth
    Richard


    Comment

    Working...