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 / Queries / April 2006

Tip: Looking for answers? Try searching our database.

Check boxes to select fields to show in a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daama - 03 Apr 2006 07:55 GMT
Hi,

I am working on a fairly simple database. I want the user to use check boxes
to select the fields to show in the query  which is linked to the master
table [tblMaster]. I aleready got the query to a point where it recognizes
starting data and ending data for the generated query. The problem is to
select the fields to show. can anyone help? I would greatly appreciate your
help...

Daama
Tom Ellison - 03 Apr 2006 19:07 GMT
Dear Daama:

Write VBA to access the check boxes on the form and create the SQL code for
the query.

Since all this function is occurring within the form, and will be done by an
event of the form (probably a command button) this code would go into the
forms code.

Tom Ellison

> Hi,
>
[quoted text clipped - 8 lines]
>
> Daama
Daama - 03 Apr 2006 20:07 GMT
Dear Tom,

Thanks a bunch for your suggestions. I want to show you (and to anyone else
who can help) the code i have been trying:

Dim strSQL As String

If (Me.chbxRespondentID = False) AND (Me.chbxLoanType = False) AND _
  (Me.chbxLoanAmount= False) Then
  MsgBox "You must select at least one Field."

Else
  strSQL = "SELECT "
  If (Me.chbxRespondentID = True) Then
      strSQL = strSQL & "[tblLoan]![Respondent ID], "
  End If

  If (Me.chbxLoanType = True) Then
      strSQL = strSQL & "[tblLoan]![Loan Type], "
  End If

  If (Me.chbxLoanAmount = True) Then
      strSQL = strSQL & "[tblLoan]![Loan Amount], "
  End If

  strSQL = Left(strSQL, Len(strSQL) - 2) & " FROM tblLoan"
End If

The fields I want to select using the check boxes are the following:
Respondent ID;   Loan Type;  Loan Amount],
They are all located in one table called  tblLoan.
The computer still does not recongnize the code and returns a message saying
[syntax error (missing operator) in query expression.....]

I would appreciate any help.

Thanks,
Daama

>Dear Daama:
>
[quoted text clipped - 12 lines]
>>
>> Daama

Signature

Daama

 
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.