×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How can I "refresh" a Combo Box on form without "refreshing"

How can I "refresh" a Combo Box on form without "refreshing"

How can I "refresh" a Combo Box on form without "refreshing"

(OP)
Question :
I have Three combo boxes on a form which allows the client to add new inventory records to a table.  Each Combo box has a record source query based on information contained in the other combo boxes (the user can select from a list when they click on the combo box).

The underlying data structures consist of "Department", "Class" and "SubClass", i.e. if the client selects "Hardgoods" from the Department combo box, when they click on the "Class" combo box, only the "class" descriptions for the "Hardgood" department should display.
This is the same for "SubClass", i.e. only subclass descriptions for the "Class" chosen by the user will display.

I can get this to work (sort of) by putting a Forms!Refresh in the update event of the box. This causes other problems however as since the record fields are "required" the refresh tries to "write" the new record to the table ~(before the other combo selections are made) etc. etc.


What i want to do is to get the "record source query" fior the combo box to run (or refresh) when the user clicks on the combo box (or the box gets focus)..........  but i cannot see how to do this (without "refreshing" the entire form.

In a nutshell:
Is there a way to refresh a combo box when the user clicks on it (WITHOUT refreshing the entire form?)

The data displayed is dependant on what the user selected in another combo box on the same form)

RE: How can I "refresh" a Combo Box on form without "refreshing"

You can try this...

make a new form and set its Record Source to your Table, then create 3 combo boxes names (combo1, combo2, combo3), finally put this code.

1)
   Private Sub Form_Load()
       Me.Combo1.RowSource = "Field1"
   End Sub
2)
   Private Sub Combo1_AfterUpdate()
       Me.Combo2.RowSource = "SELECT [Table].[Field2] FROM Table WHERE [Table].[Field1] = '" & Me.Combo1 & "'"
   End Sub
3)
   Private Sub combo2_AfterUpdate()
       Me.combo3.RowSource = "SELECT [Table].[Field3] FROM Table WHERE [Table].[Field1] = '" & Me.Combo1 & "' AND [Table].[Field2] = '" & Me.Combo2 & "'"
   End Sub

Note:  **my fields are of type Text**

Hope this would help YOU...

Mohamed Aly
samara_79@hotmail.com

RE: How can I "refresh" a Combo Box on form without "refreshing"

(OP)
THIS IS WONDERFUL !  WORKED BEAUTIFULLY. THANKYOU SO MUCH (BEING NEW TO ACCESS I AM LEARNING AS I GO AND WITHOUT THE HELP OF FOLKS LIKE YOU IT WOULD BE A REAL STRUGGLE, AGAIN, THANKS SO MUCH)
PAUL

RE: How can I "refresh" a Combo Box on form without "refreshing"

You could also use DoCmd.Combo2.Requery from the update event.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close