Microsoft
Software
Hardware
Network
Question : How do I load form using the same code as 'After_Update' event from searchforrecords macro?
First time on expert-exchange, struggling to get off the ground with vba.
I have a form with the Record Source pointing to a query. The query is also the Control Source
for text boxes such as Last Name, First Name, Title, Email, etc. There is a subform below the
text boxes that is specific to each employee ... the form is linked to subform on strEmail.
All works well but a user would need to click through records or search for their name, so I
added a unbound combo box which lists all emails. Users now use combo box, find their
name and the form / subform shows their information. This is accomplished with a macro using
SearchForRecord Action and a where condition of:
="[strEmail] = " & "'" & [Screen].[ActiveControl] & "'"
in the After Update property of the combo box.
Combo box is designed to find the users name when the form is opened. Problem is, the user
can see their email in the combo box, but has to click on it to fire the After Update event and
then the form / subform shows their information.
I converted macro to VBA and used that code in the After_Update event (in place of macro):
Private Sub Combo27_AfterUpdate()
DoCmd.SearchForRecord , "", acFirst, "[strEmail] = " & "'" & Screen.ActiveControl & "'"
End Sub
Try as I may using Form_Load, calling the After_Update, etc. I cannot get the form to open
with the form and subform showing user's information. It will only work when the combo
box is used to select their name (and then the After_Update event fires).
Can you help me ?
Answer : How do I load form using the same code as 'After_Update' event from searchforrecords macro?
Ah ... lets try this:
Private Sub Form_Load()
Me.Combo27.SetFocus ' *** add this
Combo27_AfterUpdate
End Sub
Random Solutions
Flag duplicate record
BCM, Business Contact Manager, 2010 RTM cannot connect to remote sql database
How to configure SSG-140 with multiply public IP's on single interface.
Remote Desktop not working via IP address
Could not reliably determine the server's fully qualified when trying to restart https service
BESX 5.0.1.4 and Exchange 2010 Users can't activate enterprise email
MS Access Update a field based on multiple field values
unable to browse .asmx page in IIS7
visual studio 2008 installation issue
Filtering the SSRS report based on multivalue multiple parameters passed to stored procedure