Hello everyone! I have a problem trying to get a user to be able to query the database with only the fields and specifics they want.

Basically...

User logs in, browses through record entries and then wants to see how many of the entries are under the age of 21 and instead of seeing every field in the database they just want to see the first name, last name, and of course the age.

I was thinking of having a CommandButton that brings up a form with checkboxes (to select the fields) and text boxes(to input numbers or text) and radio buttons (greater than, less than). But even after building the form I don't know the VB code to do anything that advanced.

Hopefully I explained this well enough. Thanks in advance!

First of all tell me from where you got VB 6.5 ? Is it a home grown version ? ;)

1. Use ADO (refer to ADODB library).
2. Open recordset using desired SQL.
3. Populate the controls from recordset.

My VB 6.5 is the version that is integrated with Microsoft Access 2007.

Thanks for the info. I can probably use the Help files to find out how to use ADO and recordsets. The only thing I understood was populating controls :) I'll write some of the code up and then I'll post it if it works or not so that other people with the same question can see it.

basically you need a command button, two radio buttons a textbox and a Report Form, these are all you require to perform such task.

HOW THE OPERATION IS TO BE EXECUTED
1. WRITE A VALIDATION CODE FOR THE TWO RADIO BUTTONS THAT'LL CHECK IF ONE OF IT IS SELECTED AND THEN EXECUTE THE INSTRUCTIONS EMBEDDED IN IT
* ONE OF THE OPTION BUTTONS SHOULD BE CAPTIONED "ALL AGES" AND THE OTHER ONE BE CAPTIONED "SPECIFIC AGES"
* THE "ALL AGES" SHOULD QUERY ALL THE REQUIRED FIELD AND DISPLAY IT ON YOUR FORM AND IF "SPECIFIC AGE" IS SELECTED THEN YOU'LL HAVE TO ENTER THE AGE IN YOUR TEXT BOX AND ONLY THE SPECIFIED AGE WILL BE QUERIED.

1. FROM YOUR RECORD SET YOU'LL QUERY ALL THE REQUIRED FIELDS USING YOUR TEXTBOX TO MAKE ENTRY FOR THE SPECIFIED AGE AND THE CODE TO PERFORM THIS SEARCH BE EMBEDDED UNDER YOUR COMMAND BUTTON CAPTIONED "QUERY"

2. YOUR COMMAND BUTTON SHOULD BE THE ONE TO BE CODED TO ACHIEVE ALL OF THESE


I KNOW THIS IDEA OF MINE WILL TACKLE OR SOLVE YOUR PROBLEM
THIS IS A PSEUDOCODE LIKE OF WHAT YOU NEED AND THAT IS REQUIRED IS JUST TO CONVERT IT TO VB STATEMENTS. BETTER STILL IF YOU HAVE PROBLEM WRITING THE CODE THEN YOU CAN STILL POST YOUR QUESTION

I'VE DONE THIS B4 AM NOT JUST GUESSING IT WORKS!!!

Thanks. I am about to work on this right now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.