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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why isn't this code working?

Status
Not open for further replies.

BLSguy

Instructor
Feb 9, 2017
39
US
The code I'm trying to use:

Private Sub cboModel_AfterUpdate()
Dim stQueryName As String
Dim stFormName As String
stQueryName = "qryModelParameter"
stFormName = "frmDesktopsByModel"
DoCmd.OpenQuery stQueryName, acViewNormal, acEdit
DoCmd.Close acForm, stFormName
End Sub

What it's failing to do:

I want a parameter query with a list of options for the user to choose from to open a query displaying the results. This gives me a list of options but does nothing when I click any given option.

What I'd like to do:

I'd like to use 12 button controls to represent each month. I'd like some sort of control beneath those buttons that will display the results of a parameter query that finds records limited to the users selected month. I'd then like the user to be able to double click a record to open a new form in which the ID (or other fields tied to that ID) of the selected record is already filled in on an input form. Additionally, I need some way to make a validation rule that prevents more than 12 records to be tied to a given ID.


If that's not making sense, I'll try to clarify. I'm trying to create a scheduling system. I have 10-15 classes per month. Each class can hold 6-12 students. These classes are only 4 hours, start to finish, and each student only needs to take a class once every two years. I'm simply trying to make a user friendly means of recording which students are registering for which classes, as well as a user friendly way to view available classes and spaces.

Currently, I've managed to create a query (thanks to this forum) that shows me the data I need. I've got my tables and relationships functional. I'm stuck at the dreaded coding stage, trying to figure out how to help users view data and input records. Any help would be deeply appreciated!
 
You should never open a query. You use a query as the record source of a form or a report.

All parameters must come from controls on forms.

You should probably be selecting a month and year. I would do all of this with a single form. Select a month and year from a combo box which then filters another combo box with classes that have a column with the number of students currently enrolled. This combo box could have a row source that prohibits displaying if the enrollment is maxed out.

I also think you need to get the registration out of your student table. There should be a separate junction table that has one record per student per class.

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top