Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using a Form for Parameters

I have queries which have SUMREV01 SUMREV02, etc. as fields. I'm creating a
monthly report in excel which pulls this Revenue data from access using
msquery. I want my boss to be able to select which month she'd like the data
for on a form in Excel and it pull the correct data. As the Revenues from
different months are different fields instead of criteria...I'm not sure how
to do this or if it's possible. I know I may have to use VBA but I'm not
extremely familiar with it? Is there any easier way or what is the simplest
way of accomplishing this?

Thanks!

--
whitney
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Using a Form for Parameters

You mean SUMREV01 refers to January, SUMREV02 refers to February etc.. ?
Whilst this seems a rather strange way to structure you DB, ....
You will have construct the SQL for the query table and .refresh.

Assuming you have a multiselect list box with the month:
Dim SQLText as string
Dim i as Long

With lstMonth
For i=0 to .ListCount-1
If .List(i).Selected=True Then
SQLText=SQLText & .List(i) & ", "
End If
Next
End With
'Remove trail ", "
SQLText=Left(SQLText,Len(SQLText)-2)
SQLText="SELECT " & SQLText & " FROM WhateverTable WHERE SomeCondition=True"
With qtData
.CommandType = xlCmdSQL
.CommandText =SQLText
.Refresh
End With



"Sheenalis" wrote in message
...
I have queries which have SUMREV01 SUMREV02, etc. as fields. I'm creating

a
monthly report in excel which pulls this Revenue data from access using
msquery. I want my boss to be able to select which month she'd like the

data
for on a form in Excel and it pull the correct data. As the Revenues from
different months are different fields instead of criteria...I'm not sure

how
to do this or if it's possible. I know I may have to use VBA but I'm not
extremely familiar with it? Is there any easier way or what is the

simplest
way of accomplishing this?

Thanks!

--
whitney



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using a Form for Parameters

Yes...I hate this part of the structure of the db. The company is extremely
complex but I still cannot understand their reasoning for creating it this
way. Can you explain how exactly I should restructure my queries (there are
like 100 of them)? I am creating the report for my boss and she will just be
using excel...she couldn't go into access and know enough to change the
periods and the report is extensive so I can't change every cell. I will no
longer be here in two weeks so I wanted to make it as easy for her as
possible. What exactly is the VBA you gave me doing? Sorry...I've only worked
with very basic VBA...

Thanks so much for your help.
--
whitney


"NickHK" wrote:

You mean SUMREV01 refers to January, SUMREV02 refers to February etc.. ?
Whilst this seems a rather strange way to structure you DB, ....
You will have construct the SQL for the query table and .refresh.

Assuming you have a multiselect list box with the month:
Dim SQLText as string
Dim i as Long

With lstMonth
For i=0 to .ListCount-1
If .List(i).Selected=True Then
SQLText=SQLText & .List(i) & ", "
End If
Next
End With
'Remove trail ", "
SQLText=Left(SQLText,Len(SQLText)-2)
SQLText="SELECT " & SQLText & " FROM WhateverTable WHERE SomeCondition=True"
With qtData
.CommandType = xlCmdSQL
.CommandText =SQLText
.Refresh
End With



"Sheenalis" wrote in message
...
I have queries which have SUMREV01 SUMREV02, etc. as fields. I'm creating

a
monthly report in excel which pulls this Revenue data from access using
msquery. I want my boss to be able to select which month she'd like the

data
for on a form in Excel and it pull the correct data. As the Revenues from
different months are different fields instead of criteria...I'm not sure

how
to do this or if it's possible. I know I may have to use VBA but I'm not
extremely familiar with it? Is there any easier way or what is the

simplest
way of accomplishing this?

Thanks!

--
whitney




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Using a Form for Parameters

It just builds an SQL from the items selected in a list box that contains
all the month of the year.
You then need to refresh your query table with the new query.

If you are having trouble with this code, it might be easier for you just to
get all the months data and hide what you don't want.

NickHK

"Sheenalis" wrote in message
...
Yes...I hate this part of the structure of the db. The company is

extremely
complex but I still cannot understand their reasoning for creating it this
way. Can you explain how exactly I should restructure my queries (there

are
like 100 of them)? I am creating the report for my boss and she will just

be
using excel...she couldn't go into access and know enough to change the
periods and the report is extensive so I can't change every cell. I will

no
longer be here in two weeks so I wanted to make it as easy for her as
possible. What exactly is the VBA you gave me doing? Sorry...I've only

worked
with very basic VBA...

Thanks so much for your help.
--
whitney


"NickHK" wrote:

You mean SUMREV01 refers to January, SUMREV02 refers to February etc.. ?
Whilst this seems a rather strange way to structure you DB, ....
You will have construct the SQL for the query table and .refresh.

Assuming you have a multiselect list box with the month:
Dim SQLText as string
Dim i as Long

With lstMonth
For i=0 to .ListCount-1
If .List(i).Selected=True Then
SQLText=SQLText & .List(i) & ", "
End If
Next
End With
'Remove trail ", "
SQLText=Left(SQLText,Len(SQLText)-2)
SQLText="SELECT " & SQLText & " FROM WhateverTable WHERE

SomeCondition=True"
With qtData
.CommandType = xlCmdSQL
.CommandText =SQLText
.Refresh
End With



"Sheenalis" wrote in message
...
I have queries which have SUMREV01 SUMREV02, etc. as fields. I'm

creating
a
monthly report in excel which pulls this Revenue data from access

using
msquery. I want my boss to be able to select which month she'd like

the
data
for on a form in Excel and it pull the correct data. As the Revenues

from
different months are different fields instead of criteria...I'm not

sure
how
to do this or if it's possible. I know I may have to use VBA but I'm

not
extremely familiar with it? Is there any easier way or what is the

simplest
way of accomplishing this?

Thanks!

--
whitney






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
parameters DavidC Excel Discussion (Misc queries) 3 October 12th 09 06:48 PM
Pass variable from form to form to form headly Excel Programming 1 May 31st 06 02:50 AM
Too few parameters lou sanderson Excel Discussion (Misc queries) 1 January 13th 06 06:35 PM
Too few parameters lou sanderson Excel Programming 1 January 13th 06 06:35 PM
too few parameters lou sanderson Excel Programming 1 December 14th 05 07:53 PM


All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"