By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,082 Members | 2,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,082 IT Pros & Developers. It's quick & easy.

display combo box value at Form load event isue

P: 46
Hi community experts,

May I knw hw can the values of the combo box be displayed at combo box afterupdate event. I want to achieve in such a way whereby at the form load the value displayed at the combo box will be displayed at the textboxs as well.
Let say S1 happens to be displayed in form load, which mean that values (StudentId, name) corresponding to S1 will be displayed as well.

Expand|Select|Wrap|Line Numbers
  1. Combo box - StudentId (unbounded)
  2. TextBoxes - StudentId (unbounded)
  3.                    name (unbounded)
Code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_AfterUpdate(Cancel As Integer)
  2. Dim stud As Variant
  3. stud = DLookup("StudentId", "Student", "StudentId = '" & Me.Combo1.Column(0) & "'")
  4. Me.StudentId.Value = stud
  5. End Sub
Feb 7 '07 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,366
Hi community experts,

May I knw hw can the values of the combo box be displayed at combo box afterupdate event. I want to achieve in such a way whereby at the form load the value displayed at the combo box will be displayed at the textboxs as well.
Let say S1 happens to be displayed in form load, which mean that values (StudentId, name) corresponding to S1 will be displayed as well.

Combo box - StudentId (unbounded)
TextBoxes - StudentId (unbounded)
name (unbounded)

Code
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Combo1_AfterUpdate(Cancel As Integer)
  3. Dim stud As Variant
  4. stud = DLookup("IStudentId", "Student", "StudentId = '" & Me.Combo1.Column(0) & "'")
  5. Me.StudentId.Value = stud
  6. End Sub.
If you want it the code to run at form load then put the code in the form's On Load event.

Also, you don't need the mediating stud variable you can just go ahead and assign it directly to StudentId.Value.
Feb 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.