Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
0
0
US
Question :<br>I have Three combo boxes on a form which allows the client to add new inventory records to a table.&nbsp;&nbsp;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). <br><br>The underlying data structures consist of &quot;Department&quot;, &quot;Class&quot; and &quot;SubClass&quot;, i.e. if the client selects &quot;Hardgoods&quot; from the Department combo box, when they click on the &quot;Class&quot; combo box, only the &quot;class&quot; descriptions for the &quot;Hardgood&quot; department should display.<br>This is the same for &quot;SubClass&quot;, i.e. only subclass descriptions for the &quot;Class&quot; chosen by the user will display.<br><br>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 &quot;required&quot; the refresh tries to &quot;write&quot; the new record to the table ~(before the other combo selections are made) etc. etc.<br><br><br>What i want to do is to get the &quot;record source query&quot; fior the combo box to run (or refresh) when the user clicks on the combo box (or the box gets focus)..........&nbsp;&nbsp;but i cannot see how to do this (without &quot;refreshing&quot; the entire form.<br><br>In a nutshell: <br>Is there a way to refresh a combo box when the user clicks on it (WITHOUT refreshing the entire form?)<br><br>The data displayed is dependant on what the user selected in another combo box on the same form)
 
You can try this...<br><br>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.<br><br>1)<br>&nbsp;&nbsp;&nbsp;Private Sub Form_Load()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.Combo1.RowSource = &quot;Field1&quot;<br>&nbsp;&nbsp;&nbsp;End Sub<br>2)<br>&nbsp;&nbsp;&nbsp;Private Sub Combo1_AfterUpdate()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.Combo2.RowSource = &quot;SELECT
.[Field2] FROM Table WHERE
.[Field1] = '&quot; & Me.Combo1 & &quot;'&quot;<br>&nbsp;&nbsp;&nbsp;End Sub<br>3) <br>&nbsp;&nbsp;&nbsp;Private Sub combo2_AfterUpdate()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.combo3.RowSource = &quot;SELECT
.[Field3] FROM Table WHERE
.[Field1] = '&quot; & Me.Combo1 & &quot;' AND
.[Field2] = '&quot; & Me.Combo2 & &quot;'&quot;<br>&nbsp;&nbsp;&nbsp;End Sub<br><br>Note:&nbsp;&nbsp;**my fields are of type Text**<br><br>Hope this would help YOU...<br> <p>Mohamed Aly<br><a href=mailto:samara_79@hotmail.com>samara_79@hotmail.com</a><br><a href= > </a><br>
 
THIS IS WONDERFUL !&nbsp;&nbsp;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)<br>PAUL
 
You could also use DoCmd.Combo2.Requery from the update event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top