Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a check bow to select text box data

Status
Not open for further replies.

kpryan

Technical User
Aug 24, 2005
282
US
Hi,
Is it possible to relate a check box to a text field so that when it is checked that data can form a query so that a report can be generated only with that chosen data?
If it is how would this be done?

Many thanks,
Ken
 
How are ya kpryan . . .

If the checkbox is in the table just make a query with criteria set to look for the checkbox fieldname value = true . . .
Code:
[blue]   SELECT * 
   FROM [purple][b][i]TableName[/i][/b][/purple] 
   WHERE ([[purple][b][i]CheckboxName[/i][/b][/purple]] = True);[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
If the checkbox doesn't relate to a table field, what you would do is generate the query SQL in code. E.g.,

Code:
Dim strSQL as String

strSQL = "SELECT * FROM tblData WHERE "

If [chkOne] Then
  strSQL = strSQL & "[Field1] = '" & txtOne & "' AND "
End If
// additional conditions as desired for any
// number of checkbox / text field pairs

// strip trailing " AND "
strSQL = left(strSQL, Len(strSQL - 5))

// do something with your query (like DoCmd.OpenForm)

I don't see this one in the FAQs, but it ought to be, really.

TMTOWDI - it's not just for Perl any more
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top