Hi all
How do I do this? I want to have a form that opens with Author info. On the form is a table with books by the author (book title, year, publisher), and when the user selects a book in the table and clicks a 'Show Detail' button, a subform becomes visible with detailed information about that book (genre, plot synopsis, characters, notes etc).
What I've done
I have a form with two subforms. Subform1 is a datasheet view (table) of the selected columns. Subform2 has controls to show one one book and is initially non-Visible. I set the RecordSource for Subform2 in the (sub)Form_Open event using a getBookId function to identify the correct book, but, because subforms open before their forms, the initial record to be displayed is set to 0. This is reasonable at Form open time. When a different book is selected in the table, the setBookId function is invoked by the table's (actually the Form's) _Current method and Subform2 is Requery'ed. However, debug.print shows that the RecordSource sql is still querying where BookId = 0 (ie the initial value), and not the value returned by getBookId.
Does the record source sql get 'inline'd when declared from Form_Open in a subform? How do I change the sql to query a different record except through a variable and getters and setters. Should I dim a local copy of BookId in the subform, and have the query use that instead of calling getBookId (which is in a separate module)? I'm a bit confused.
tia
mcalex
How do I do this? I want to have a form that opens with Author info. On the form is a table with books by the author (book title, year, publisher), and when the user selects a book in the table and clicks a 'Show Detail' button, a subform becomes visible with detailed information about that book (genre, plot synopsis, characters, notes etc).
What I've done
I have a form with two subforms. Subform1 is a datasheet view (table) of the selected columns. Subform2 has controls to show one one book and is initially non-Visible. I set the RecordSource for Subform2 in the (sub)Form_Open event using a getBookId function to identify the correct book, but, because subforms open before their forms, the initial record to be displayed is set to 0. This is reasonable at Form open time. When a different book is selected in the table, the setBookId function is invoked by the table's (actually the Form's) _Current method and Subform2 is Requery'ed. However, debug.print shows that the RecordSource sql is still querying where BookId = 0 (ie the initial value), and not the value returned by getBookId.
Does the record source sql get 'inline'd when declared from Form_Open in a subform? How do I change the sql to query a different record except through a variable and getters and setters. Should I dim a local copy of BookId in the subform, and have the query use that instead of calling getBookId (which is in a separate module)? I'm a bit confused.
tia
mcalex