Command Boxes and List Boxes

  • Thread starter Thread starter Shaundra
  • Start date Start date
S

Shaundra

I added 2 command boxes in a form. In the first box, I
want to be able to type a code in that command box, which
will cause the second command box to autofill that codes
definition and the list box at the bottom of the same
form will list just the records that match the funding
plan typed in at the top(data source for the 2 command
buttons: is called 'CAAP Funding Plan Definitions' & the
list box data source comes from a table called NONCOM'04).

Can you help me with the syntax of this which I can put
in VBA to make this work???? Help! (thanks)
 
Shaundra,

Firstly, I think you're talking about Text boxes, rather than Command boxes.

If I understand you correctly, you want to have a listbox display its
contents based on what you've typed into the textbox. If that's what you
want then the following pseudo-code will demonstrate how to do it: Add the
following code to the text box's AfterUpdate event (making sure to change
the names to reflect the names of the controls you've used):

....If the textbox's value is numeric...
Me.lstMyListBox.RowSource = "SELECT blah, blah1, blah2 FROM tblSomeTable
WHERE somefield = " & Me.txtMyTextBox

....If the textbox's value is alpha/alphanumeric...
Me.lstMyListBox.RowSource = "SELECT blah, blah1, blah2 FROM tblSomeTable
WHERE somefield = """ & Me.txtMyTextBox & """"

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top