D
Don
Currently my Access DB has a form whose 'Record Source' property is set to a
query. The query is pretty simply in that selects all fields and all
records from a table with personnel data then orders them by last name then
first name. The SQL view of the query is:
SELECT tblPrimary.*
FROM tblPrimary
ORDER BY tblPrimary.[Last Name], tblPrimary.[First Name];
On the form are numerous subforms which show data from other tables. The
data in these tables is linked to the individual's record in tblPrimary
using a field called LinkID which is nothing more than randomly generated,
unique numerical identifier for each individual. For a variety of reasons,
I want to move the 'Record Source' selection into the event code of the
form. So I inserted the following into the Form_Open event:
Dim strSQL As String
strSQL = "SELECT tblPrimary.* " _
& "FROM tblPrimary " _
& "ORDER BY ORDER BY tblPrimary.[Last Name], tblPrimary.[First Name]"
Me.RecordSource = strSQL
However, now when I open the form I get numerous message boxes asking for a
value for LinkID.
Best I can figure, the subforms are being processed prior to the Form_Open
event so LinkID is "undefined" and therefore all the message boxes
requesting the value for LinkID. From this I am concluding that when the
'Record Source' is entered as a property of the form it is somehow processed
before subforms. However, if the 'Record Source' for a form is set
programmatically, subforms are processed first.
So, do I need to change the fundamental structure of my form? Or is there
some way to manipulate the order the form is processed? With regard to the
latter, how does one get around the fact that according to the
documentation:
When you first open a form, the following events occur in this order:
Open ? Load ? Resize ? Activate ? Current
Any solutions, observations, comments, etc will be greatly appreciated!
Thanks!
Don
query. The query is pretty simply in that selects all fields and all
records from a table with personnel data then orders them by last name then
first name. The SQL view of the query is:
SELECT tblPrimary.*
FROM tblPrimary
ORDER BY tblPrimary.[Last Name], tblPrimary.[First Name];
On the form are numerous subforms which show data from other tables. The
data in these tables is linked to the individual's record in tblPrimary
using a field called LinkID which is nothing more than randomly generated,
unique numerical identifier for each individual. For a variety of reasons,
I want to move the 'Record Source' selection into the event code of the
form. So I inserted the following into the Form_Open event:
Dim strSQL As String
strSQL = "SELECT tblPrimary.* " _
& "FROM tblPrimary " _
& "ORDER BY ORDER BY tblPrimary.[Last Name], tblPrimary.[First Name]"
Me.RecordSource = strSQL
However, now when I open the form I get numerous message boxes asking for a
value for LinkID.
Best I can figure, the subforms are being processed prior to the Form_Open
event so LinkID is "undefined" and therefore all the message boxes
requesting the value for LinkID. From this I am concluding that when the
'Record Source' is entered as a property of the form it is somehow processed
before subforms. However, if the 'Record Source' for a form is set
programmatically, subforms are processed first.
So, do I need to change the fundamental structure of my form? Or is there
some way to manipulate the order the form is processed? With regard to the
latter, how does one get around the fact that according to the
documentation:
When you first open a form, the following events occur in this order:
Open ? Load ? Resize ? Activate ? Current
Any solutions, observations, comments, etc will be greatly appreciated!
Thanks!
Don