473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Passing information from a form to SQL

I am a novice with SQL - I usually work in the query grid. However I
am trying to find a way to change a field name depending upon what I
select from a combo box on a form. I created an unbound form allows me
to select any one of 20 field names from the Questionnaire table. When
I select a new one, for example "Discharges", I want to replace the
field "Admissions" (in the SQL below) with it. I have a button on my
form that Runs Query. Can I insert some code in the On Click of that
button to change my SQL statement?
SELECT Questionnaire.[Fiscal Year], Questionnaire.Quarter,
Count(Questionnaire.[ID Code]) AS [Admissions Questions Samples]
FROM Questionnaire
WHERE (((Questionnaire.Admissions) Is Not Null And
(Questionnaire.Admissions)<>0) AND
((Questionnaire.OmitFromAnalysis)=False))
GROUP BY Questionnaire.[Fiscal Year], Questionnaire.Quarter;
Any help is very much appreciated.

Nov 16 '05 #1
1 1213

"Delores" <de******@shaw.ca> wrote
However I
am trying to find a way to change a field name depending upon what I
select from a combo box on a form. I created an unbound form allows me
to select any one of 20 field names from the Questionnaire table. When
I select a new one, for example "Discharges", I want to replace the
field "Admissions" (in the SQL below) with it. I have a button on my
form that Runs Query. Can I insert some code in the On Click of that
button to change my SQL statement?


Dim src As String
dim fName As String

fName = Me!cboFieldName.Value

src = "SELECT Questionnaire.[Fiscal Year], Questionnaire.Quarter, " & _
"Count(Questionnaire.[ID Code]) AS [Admissions Questions Samples] " & _
"FROM Questionnaire " & _
"WHERE Questionnaire." & fName & " Is Not Null And " & _
"(Questionnaire." & fName & "<>0) AND " & _
"(Questionnaire.OmitFromAnalysis=False) " & _
"GROUP BY Questionnaire.[Fiscal Year], Questionnaire.Quarter"

--
Darryl Kerkeslager
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
6
by: Max | last post by:
Last time I tried to explain this on another forum it didn't go too well, so I'll try my best and if you know what I'm talking about then please tell me how to do this. I have a class, inside I...
7
by: Drum2001 | last post by:
I am creating a database to track employee time. I have created a form that allows them to select from a combo box their task, enter their hours, and add any comments they may have. In the...
2
by: whitc26 | last post by:
Let me preface: I'm a novice, and have no programming experience. I have created an access database and have a few tables in it. I have created a form called "clients" This form opens up and...
7
by: AMP | last post by:
Hello, I have this in form1: namespace Pass { public partial class Form1 : Form { public Form2 form2; public Form1() {
1
by: rfr | last post by:
I have a need to use a single version of a Visitor Response Feedback Form on numerous HTML documents. Rather than have numerous versions of this, one on each HTML document, it makes more sense to...
10
by: patelxxx | last post by:
Problem: I am trying to input my name in a text box and I click on transfer and I want the name to appear on the same page (i.e. in another form). How is this done? <BODY> <HTML> <form...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.