View Single Post
  #12  
Old November 17th, 2009, 02:52 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Using a Combo Box to Find Records

Hi Scott,
I assume that the combo now correctly shows the first item on its list after
the form loads?
The error message comes when the next line of code runs
Call cboMoveTo_AfterUpdate


Is this what happens?
If the answer is yes, just comment out the line of code
Call cboMoveTo_AfterUpdate

and see how that goes.

That line of code was put in to simulate the user clicking the combo to
finding the records that match the SetupID for the first item on the list.
You may not need to do this.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



"Scott_Brasted via AccessMonster.com" u56211@uwe wrote in message
news:9f399cdd77161@uwe...
Jeanette,

Here is what is in imm. win:
First item on combo list is: Setup ID
But if I perservere and get past the error message, the correct data is in
the cbo.

SetupID is the autonumber primary key for the table for the main form. The
table is the list of fund raising campaigns and the field in the combo box
is
the campaign name. I get the error: The value you entered isn't valid
for
this field. Does it matter that there is a subform?

Thanks,
Scott

Jeanette Cunningham wrote:
Scott,
I am just getting back to this thread - it is 6am here in Australia.

This code--
Private Sub cboMoveTo_OnLoad()
Me.[cboMoveTo] = Me.[cboMoveTo].ItemData(0)
End Sub

is meant to make the combo show the first item that you would see if you
clicked on the combo. By the way, the line --
needs to be put in the Form_Load event.

The idea is that when the form load event runs, it puts that first item in
the combo.
The load event always runs when a form is opened.

Let's check out why this doesn't work for you.

In the code you have on the Form_Load event,
put this line
Debug.Print "First item on combo list is: " & Me.cboMoveTo.ItemData(0)

Now open the form.
Press Alt + G to open the Immediate window.
Look what access has put for the first item in the combo.

Let us know what access put in the immediate window.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Bruce,

[quoted text clipped - 107 lines]
Thanks,
Scott


--
Message posted via http://www.accessmonster.com