tranchemontaigne
Technical User
PROBLEM: I cannot figure out how to set the RecordSource property of a pop up form based upon an IsLoaded test.
APPROACH: I want to use an IsLoaded test to
1) determine which form is calling a lookup form and then 2) set the RecordSource property based upon the form that is calling it.
IMPLEMENTATION GOAL: The specific application is to populate the txtCounty and txtState text boxes on the value selected within the cboCity combo box on a calling form.
DESIRE: Rather than have a separate "lookup form" to correspond to each calling form, I want to only have only one lookup form and dynamically set the RecordSource property of that form each time. (Explicitly setting the criteria equal to [Forms]![frmCallingForm]![cboCity].value control where [frmCallingForm] would be set to the name of the calling form.)
OBSERVATION: My failed efforts involved the creation of a strSQL string containing an SQL statement and then setting the RecordSource property equal to strSQL. According to the documentation I have read, anytime you assign a new RecordSource property to a control or form, the control or form is requeried. My code fails to get this far along though. It produces application errors as soon as the strSQL string is defined.
SECONDARY QUESTION: I know that using a pop up form is a clunky way of completing this task. Does anyone have thoughts on a pure VBA approach to auto-completing fields that does not involve opening lookup forms?
Thanks in advance
APPROACH: I want to use an IsLoaded test to
1) determine which form is calling a lookup form and then 2) set the RecordSource property based upon the form that is calling it.
IMPLEMENTATION GOAL: The specific application is to populate the txtCounty and txtState text boxes on the value selected within the cboCity combo box on a calling form.
DESIRE: Rather than have a separate "lookup form" to correspond to each calling form, I want to only have only one lookup form and dynamically set the RecordSource property of that form each time. (Explicitly setting the criteria equal to [Forms]![frmCallingForm]![cboCity].value control where [frmCallingForm] would be set to the name of the calling form.)
OBSERVATION: My failed efforts involved the creation of a strSQL string containing an SQL statement and then setting the RecordSource property equal to strSQL. According to the documentation I have read, anytime you assign a new RecordSource property to a control or form, the control or form is requeried. My code fails to get this far along though. It produces application errors as soon as the strSQL string is defined.
SECONDARY QUESTION: I know that using a pop up form is a clunky way of completing this task. Does anyone have thoughts on a pure VBA approach to auto-completing fields that does not involve opening lookup forms?
Thanks in advance