Coding causing confusion - to me

Crackers

Registered User.
Local time
Today, 20:18
Joined
May 31, 2002
Messages
36
Yesterday I posted a question and rec'd good advice but as usual I don't think I explained myself very well.
As the attached picture of my Form shows, I have a checkbox for each Age Group under each Team. I originally had a query that would come up for each Team's particular Age Group and then the required data copuld be input. This leads to too many querys clogging things up. I tried to copy the SQL code of one of the query's to the On_Click event of the checkbox but as I have been informed SQL is different to VB.
All I would like to know is how to convert the SQL to VB coding so that I can continue to do the coding for each Checkbox.
The SQL code for the first checkbox is:

SELECT tblPlayerRegister.Surname, tblPlayerRegister.[First Name], tblPlayerRegister.Age, tblPlayerRegister.[D'n], tblPlayerRegister.G1, tblPlayerRegister.SP, tblPlayerRegister.Age2, tblPlayerRegister.G1A
FROM tblPlayerRegister
WHERE (((tblPlayerRegister.Age)<11) AND ((tblPlayerRegister.Club)="Beaconsfield"))
ORDER BY tblPlayerRegister.Surname, tblPlayerRegister.[First Name];

If there is an easier way, by all means let me know.
Any assistance would be greatfully appreciated.
 

Attachments

  • FormViewClip.jpg
    FormViewClip.jpg
    62.9 KB · Views: 148
I don't think I am an expert at explaining things but a few thoughts for you.
First stop thinking of converting SQL to VBA. You have check boxes and option buttons. So code the buttons with VBA.
For example, on your Beaconsfield group. From the toolbox use "Option group" follow the setup... ie... U12, next U11, so on. This will asign a value 1,2,3, so on.... to each option button. Then you can code a "Select Case" to return what you want.

For example....

Private Sub OptionGroupName_AfterUpdate()


Select Case Me.OptionGroupName

Case Is = 1 'Case equals 1 if your first option is picked
Me.SomeField.Visible = False

Case Is = 2
Me.SomeField.Visible = True

End Select
End Sub

This one just changes the visibility of "Somefield" depending on which option is picked.

I also think we are guessing at what end result you are going for. I am guessing filling in criteria in a query.
So build your query....... Then use a "Select case" or "If...Then" statement to fill in the criteria, then run your query to get your results.

Well, thats my 2 cents worth....:D

Maybe others will add some insight.
 

Users who are viewing this thread

Back
Top Bottom