Link to home
Start Free TrialLog in
Avatar of exceter
exceterFlag for Kyrgyzstan

asked on

Access report does not work after Upsizing to SQL SERVER

Hi

I have:
form  - myForm
control - myInputBox
report - myReport

the report is build according to value of myInputBox

it is called from in ButtonClick

Private Sub Button_Click()
    DoCmd.OpenReport "Report", acPreview
End Sub

The RecordSource of Report is :
Select * from Table(@Forms___myForm___myInputBox)

The above does not work of course (The result of Upsizing to SQL SERVER)

How to redo that ?
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

I don't know what that recordsource is supposed to do.  I can't see how it ever worked, so I don't see that it doesn't work after upsizing to be remarkable.
Do you use an Access data Project or ODBC?
Can you clarify what the user would enter into the Textbox field? It appears that you pass the name of a table?

Typically I would call the report with the contents of the textBox as the OpenArgs parameter.

DoCmd.OpenReport "Report", acPreview,,,, Me.myInputBox

Then trap the Open event of the report and create the SQL statement there on the fly and adjust the report's recordsource.

I'll try and find a code example...


ASKER CERTIFIED SOLUTION
Avatar of borki
borki
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exceter

ASKER

Sorry, I use .adb

after Upsizing the adp does not recognize (@Forms___myForm___myInputBox), and instead of reading its value, it always pops up with an Inputbox and requires user to enter data.
That data is passed to query as a parameter.
And the query result will depent on that parameter.

SELECT * FROM TABLE WHERE col1 = Parameter
The you need to rework that form's Recordsource to show the correct values. Where are you getting the value of "Parameter"?
Have you studied my sample code? It is what I use in a .adp and it works great.

You can't trust the upsizing wizard to have everything working. I generally create the reports record source, then remove all WHERE criteria and add it at runtime as in my sample code.

If you can't work it out, you could post the.adp, and the SQL Create code from the table. This is usually obtained from SQL Management Studio, right click on the table and select 'CREATE to clipboard'.
Avatar of exceter

ASKER

>If you can't work it out, you could post the.adp, and the SQL Create code from the table. This is usually obtained >from SQL Management Studio, right click on the table and select 'CREATE to clipboard'.

I would post it with a pleasure, but it is in Russian, I am afraid you can't open it.

the query I need is:

SELECT * FROM ContIN WHERE PostDATE BETWEEN datain1 and datein2

Avatar of exceter

ASKER

I I found it. but look at the following:

SELECT * FROM ContIN
 WHERE (datePOST BETWEEN CONVERT(varchar,'01.01.2009',112) AND CONVERT(varchar,'31.12.2009',112))

I got it from SQL Profiler it is the query from Access Report. In Access it pops-up error:

Run-time error '242'.
The conversion of varchar data type to datetime data type resulted in an out-of-range value.


If I run the above code in Management Studio, it works fine.

Where to dig ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exceter

ASKER

tnx. solved it