Passing Parameters to Access Report from VB.Net

  • Thread starter Elle Short via .NET 247
  • Start date
E

Elle Short via .NET 247

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 nowherecondition clause in my .net ...report prints correctly.

As soon as I add the parameter to my Access query, and thewherecondition 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(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Me.txtUKey.Text = 112 'just a test number to pass
Dim oAccess As Access.Application
oAccess = New Access.ApplicationClass()
oAccess.OpenCurrentDatabase(filepath:="c:\Inetpub\wwwroot\tribalastprgs\AstPrgData.mdb", exclusive:=False)
oAccess.DoCmd.OpenReport(ReportName:="HCSPRpt",View:=Access.AcView.acViewNormal, _
wherecondition:="[ukey]=" & Me.txtUKey.Text)



Thanks!! I appreciate any help you send my way. Elle
 
G

Guest

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
 

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