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
wcf upload size limitation
Reducing bandwidth consumption between domain controllors at multiple sites
sql query help.
Secondary active directory not functioning as a login server
Respose time slow
difference between AD integrated dns server and dns server
windows 7 dual monitor not working
Urgent: How to locate the current in use ID file in Lutus Notes 7
Apache webserver Linux and Gzip
MS Excel 2007 & PDF - Exporting to PDF takes long hours!