Check boxes to select fields to show in a query

  • Thread starter Thread starter Daama
  • Start date Start date
D

Daama

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
 
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
 
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

Tom said:
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
[quoted text clipped - 8 lines]
 
Back
Top