Not sure if this should be posted here for the VBA forum, but I figured the Form area would be the right place to start.
I'm trying to open a form I've created using a button. The button would contain the code to open the form with records based on the specified query in the VBA. No matter what I try, somehow it just won't work and I don't know why. When I click the button, I get windows popping up asking me for information that shouldn't be required. The query behind the form runs just fine with no errors or required input from me. So I can't figure out why I'm getting asked to give ID numbers.
So I used the Form Wizard and created a form based on the query. Just took all the defaults. Form opens fine and only has the records that are selected by the query. I then went into the form, deleted the entry in 'Record source', which was the query, and then tried to open the form using this code:
(where stDocName is the Form, and stQuery is the Query).
The form opens and every field has "#Name?" in it. If I leave the name of the query as the Record Source and try to open it with the VBA, Access prompts me to to enter the parameter value "tblSongsPlayed.SongID". If I enter a number I get a blank record. If I just hit OK, I get the correct list of records (just discovered this).
So why is it asking me for a value for "tblSongsPlayed.SongID"? And I still go back to my original question, how do I create a form that will allow me to change the source of the records using VBA?
I'm not sure what additional information you all need to debug this. I'll try to describe what's going on here. The database is for saving song information and tracking performances. I'm trying to minimize the number of forms I have as whenever I change a form I have to change it several other times, etc. The query I wrote selects all songs that have never been performed.
Here's the database setup:
Relationships
Query Builder
SQL Statement
Thanks!!
Matt
I'm trying to open a form I've created using a button. The button would contain the code to open the form with records based on the specified query in the VBA. No matter what I try, somehow it just won't work and I don't know why. When I click the button, I get windows popping up asking me for information that shouldn't be required. The query behind the form runs just fine with no errors or required input from me. So I can't figure out why I'm getting asked to give ID numbers.
So I used the Form Wizard and created a form based on the query. Just took all the defaults. Form opens fine and only has the records that are selected by the query. I then went into the form, deleted the entry in 'Record source', which was the query, and then tried to open the form using this code:
Code:
DoCmd.OpenForm stDocName, acNormal, stQuery, , , acWindowNormal
(where stDocName is the Form, and stQuery is the Query).
The form opens and every field has "#Name?" in it. If I leave the name of the query as the Record Source and try to open it with the VBA, Access prompts me to to enter the parameter value "tblSongsPlayed.SongID". If I enter a number I get a blank record. If I just hit OK, I get the correct list of records (just discovered this).
So why is it asking me for a value for "tblSongsPlayed.SongID"? And I still go back to my original question, how do I create a form that will allow me to change the source of the records using VBA?
I'm not sure what additional information you all need to debug this. I'll try to describe what's going on here. The database is for saving song information and tracking performances. I'm trying to minimize the number of forms I have as whenever I change a form I have to change it several other times, etc. The query I wrote selects all songs that have never been performed.
Here's the database setup:
Relationships
Query Builder
SQL Statement
Thanks!!
Matt