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
Import vs. link
xml are both of the examples below valid?
Dot Net IL Code to C# conversion
Why RTRIM so slow on UPDATE
new keyboard not recognised before logon
IE8 annoying advertising popups on double underlined links in webpages
Changing Server Name with Exchange 2010 Installed
My Computer prints Very Tiny on Fresh Install
Access 2007 Update subform values with another subform
How to enable VSS Writer for Exchange 2003 and SQL 2005