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 / Reports / Printing / December 2005

Tip: Looking for answers? Try searching our database.

Please help in this dynamic query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ismail - 28 Nov 2005 21:07 GMT
This is the code i have in report open event.....

what is the problem...i get "enter parameter " message when run the report

Dim asDB As Database
Dim r1s As Recordset

Dim strSQL As String
Dim d8, d9 As Variant

Set asDB = CurrentDb

d8 = Forms!searchfrm!activitycmb

strSQL = "SELECT " & d8 & ",dateofS,totalS ,stid FROM details where stid=" &
Forms!searchfrm!stidcmb & ""
strSQL = Replace(strSQL, " & Forms!searchfrm!stidcmb & ",
Forms!searchfrm!activitycmb)

Set r1s = asDB.OpenRecordset(strSQL)

   Me.RecordSource = strSQL
   r1s.MoveFirst

With r1s
   Do While Not .EOF
       Me.Text12.ControlSource = r1s("totals")
       
       r1s.MoveNext

Loop
End With

kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 29 Nov 2005 03:49 GMT
Try place a breakpoint prior to or on this line
 Set r1s = asDB.OpenRecordset(strSQL)
When the code breaks, open the debug window (press Ctrl+G) and enter
 ? strSQL
Copy the value of strSQL and paste it into a new blank query.

Let us know what happens.

Signature

Duane Hookom
MS Access MVP

> This is the code i have in report open event.....
>
[quoted text clipped - 31 lines]
>
> kindly help me ....i spent days ..no use .....thanks
ismail - 29 Nov 2005 06:44 GMT
yes i did as you told......

SELECT Store,dateofS,totalS ,stid FROM details where stid=1

this is the value and if i run this in new blank query..i get the result...

please reply...Thanks

> Try place a breakpoint prior to or on this line
>   Set r1s = asDB.OpenRecordset(strSQL)
[quoted text clipped - 39 lines]
> >
> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 29 Nov 2005 07:05 GMT
There is probably a control or sorting level bound to a field that isn't in
the record source.

If you can't figure this out, consider providing information on why you are
opening a recordset in a report.

Signature

Duane Hookom
MS Access MVP

> yes i did as you told......
>
[quoted text clipped - 50 lines]
>> >
>> > kindly help me ....i spent days ..no use .....thanks
ismail - 29 Nov 2005 08:39 GMT
I see there is no bound control or sorting on this field...

please give me instruction what to do...? i just want to show the output
in the report...i am doing this first time...(calling report and assigning
recordsource
through vba...)...please change  my code according the right way..to do this..

Thanks

> There is probably a control or sorting level bound to a field that isn't in
> the record source.
[quoted text clipped - 56 lines]
> >> >
> >> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 30 Nov 2005 03:43 GMT
You have never told us what the parameter prompt message is.

You can set the Record Source property of a report on the Open event of the
report. You shouldn't need to create a recordset.

Signature

Duane Hookom
MS Access MVP

>I see there is no bound control or sorting on this field...
>
[quoted text clipped - 68 lines]
>> >> >
>> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 30 Nov 2005 05:34 GMT
The message box is

"Enter Parameter value"   ----Title
 2232.45                        -    value of the field which i want to
display  in the report
                                     -   Empty text box
 ok     cancel

and what is right way or syntax to assign recordsource to report in open
event of report..i create recordset in form and how can i pass to report..or
how can i assign
to report..please kindly help me

 Thanks

> You have never told us what the parameter prompt message is.
>
[quoted text clipped - 73 lines]
> >> >> >
> >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 30 Nov 2005 07:38 GMT
I think it is not possible ? is it?

> The message box is
>
[quoted text clipped - 88 lines]
> > >> >> >
> > >> >> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 30 Nov 2005 17:08 GMT
Do you have a field named "2232.45"? I doubt this is possible since the
period is not allowed in field/column names.

Signature

Duane Hookom
MS Access MVP
--

>I think it is not possible ? is it?
>
[quoted text clipped - 100 lines]
>> > >> >> >
>> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 01 Dec 2005 06:59 GMT
i found that ...this number is one of the values in the table...

> Do you have a field named "2232.45"? I doubt this is possible since the
> period is not allowed in field/column names.
[quoted text clipped - 103 lines]
> >> > >> >> >
> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 01 Dec 2005 07:01 GMT
and i asked what is the normal procedure ..(.i mean syntax  ...) i should
follow..
please i am waiting for ur reply.

many thanks

> Do you have a field named "2232.45"? I doubt this is possible since the
> period is not allowed in field/column names.
[quoted text clipped - 103 lines]
> >> > >> >> >
> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 01 Dec 2005 14:38 GMT
I expect you are having an issue with this line:
      Me.Text12.ControlSource = r1s("totals")
Would you expect the value of [Totals] in the record set to be a number like
2232.45? Your code is setting the control source to a number when it should
either:
- set the Value to a number
      Me.Text12.Value = r1s("totals")
- set the control source to a field name from the report's record soru
      Me.Text12.ControlSource = "[totals]"

I still don't understand why you don't just bind your report to a saved
query.
Signature

Duane Hookom
MS Access MVP
--

> and i asked what is the normal procedure ..(.i mean syntax  ...) i should
> follow..
[quoted text clipped - 118 lines]
>> >> > >> >> >
>> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 01 Dec 2005 17:51 GMT
Dear sir....kindly look into this....

This is because of my table struct....i have fields like this

stid
stname
dateofS
Petrol
diesel
motel
oil
restaurant
store
..
..

so if i want to make report monthly,yearly...
depends upon the selection of the user like month,year,petrol or diesel or
motel.....and
station1 or station2 or station3....etc........i have to make many queries
and many reports
is not it ?

Thanks for your time

> I expect you are having an issue with this line:
>        Me.Text12.ControlSource = r1s("totals")
[quoted text clipped - 130 lines]
> >> >> > >> >> >
> >> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 01 Dec 2005 18:51 GMT
Consider normalizing your table and you would not have an issue. Petrol,
Diesel, Motel,... should all be values in a field and not a field name. You
could probably get by with one query and one report and absolutely no code
if your table structure was normalized.

If you can't or won't normalize, you should consider using a UNION query to
normalize your table:
SELECT stid, stname, dateOfS, Petrol as TheValue, "Petrol" as Category
FROM details
UNION ALL
SELECT stid, stname, dateOfS, Diesel, "Diesel"
FROM details
UNION ALL
SELECT stid, stname, dateOfS, Motel, "Motel"
FROM details
UNION ALL
---etc---

Signature

Duane Hookom
MS Access MVP

> Dear sir....kindly look into this....
>
[quoted text clipped - 168 lines]
>> >> >> > >> >> >
>> >> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 01 Dec 2005 21:31 GMT
...i hope this will do ....i will come back to you after i check...i hope
this will do...???

many thanks

> Consider normalizing your table and you would not have an issue. Petrol,
> Diesel, Motel,... should all be values in a field and not a field name. You
[quoted text clipped - 186 lines]
> >> >> >> > >> >> >
> >> >> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 03 Dec 2005 09:56 GMT
so i will get petrol, diesel,motel,restarnt .....values in one column and
categories  petrol,diesel,motel,restarnt... in other column
by using category value i have to select the value  of petrol...diesel.....etc

am i correct?

Please reply....
Thanks

> ...i hope this will do ....i will come back to you after i check...i hope
> this will do...???
[quoted text clipped - 191 lines]
> > >> >> >> > >> >> >
> > >> >> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
Duane Hookom - 03 Dec 2005 18:12 GMT
Your union query results would have fields/columns of stid, stname, dateOfS,
TheValue, Category. To find all the Petrol values, your query would look
like:
   SELECT *
   FROM quniYourUnionQuery
   WHERE Category = "Petrol";
If you want Petrol and Motel, use:

   SELECT *
   FROM quniYourUnionQuery
   WHERE Category IN ("Petrol","Motel");

Signature

Duane Hookom
MS Access MVP
--

> so i will get petrol, diesel,motel,restarnt .....values in one column and
> categories  petrol,diesel,motel,restarnt... in other column
[quoted text clipped - 226 lines]
>> > >> >> >> > >> >> >
>> > >> >> >> > >> >> > kindly help me ....i spent days ..no use .....thanks
ismail - 04 Dec 2005 13:19 GMT
East or West You R BEST

Many Thanks

> Your union query results would have fields/columns of stid, stname, dateOfS,
> TheValue, Category. To find all the Petrol values, your query would look
[quoted text clipped - 218 lines]
> >> > >> >> >> > >> >> > stid="
> >> > >> >> >> > >> >> > &
Duane Hookom - 04 Dec 2005 17:46 GMT
Glad to be of assistance.

Signature

Duane Hookom
MS Access MVP
--

> East or West You R BEST
>
[quoted text clipped - 237 lines]
>> >> > >> >> >> > >> >> > stid="
>> >> > >> >> >> > >> >> > &
 
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.