combo box text property

  • Thread starter Thread starter sparkane
  • Start date Start date
S

sparkane

I have a user who would like the position in a combo box to be
remembered between times when the user access the form holding the combo
box. So: user opens form A, enters value B into box. Later, user opens
form A, and value B appears in box automatically.

Normally this would be a simple procedure of setting the box to whatever
value was in the combo box previously. Ah, but there's a curve ball.
The row source for the combo box is a union query, which gets the same
list of Account IDs with last name first, first name first, and Account
ID first. This is to allow the user to select the account based on
different pieces of information. So the same _value_ appears in the
list multiple times, and using the _value_ to find what the user entered
previously doesn't really work, because the user wants to be at the
exact place in the list that she typed in before.

So, I've tried saving the string the user types in, and inserting it
into the combo box using the Text property. Unfortunately, this
automatically calls the AfterUpdate sub of the combo box. I won't go
into detail, but this can't happen.

I've tried inserting the saved string short one letter; however, this
raises an error that the item isn't in the list.

Can anyone tell me of a way to insert text into the combo box so that it
doesn't trigger an event; or some other way to go about doing this?

Thanks in advance.
 
sparkane said:
I have a user who would like the position in a combo box to be
remembered between times when the user access the form holding the combo
box. So: user opens form A, enters value B into box. Later, user opens
form A, and value B appears in box automatically.

Normally this would be a simple procedure of setting the box to whatever
value was in the combo box previously. Ah, but there's a curve ball.
The row source for the combo box is a union query, which gets the same
list of Account IDs with last name first, first name first, and Account
ID first. This is to allow the user to select the account based on
different pieces of information. So the same _value_ appears in the
list multiple times, and using the _value_ to find what the user entered
previously doesn't really work, because the user wants to be at the
exact place in the list that she typed in before.

So, I've tried saving the string the user types in, and inserting it
into the combo box using the Text property. Unfortunately, this
automatically calls the AfterUpdate sub of the combo box. I won't go
into detail, but this can't happen.

I've tried inserting the saved string short one letter; however, this
raises an error that the item isn't in the list.

Can anyone tell me of a way to insert text into the combo box so that it
doesn't trigger an event; or some other way to go about doing this?


Rather than setting the Text property, try setting the Value
property.

Another thing you might want to try, if the combo's list
doesn't change, is to use the ListIndex property (must have
the focus to set this).
 
Marshall Barton said:
Rather than setting the Text property, try setting the Value
property.

Thanks for the response. As I pointed out in my post, I can't use the
Value property. Re-read it if you like, or you can just take my word
for it going forward.
Another thing you might want to try, if the combo's list
doesn't change, is to use the ListIndex property (must have
the focus to set this).

This property is RO right? Once I save the list index value, how do I
navigate to that position in the list (without using the value at that
position)?

Thanks again,
spark
 
sparkane said:
Marshall Barton said

Thanks for the response. As I pointed out in my post, I can't use the
Value property. Re-read it if you like, or you can just take my word
for it going forward.


This property is RO right? Once I save the list index value, how do I
navigate to that position in the list (without using the value at that
position)?


Inspite of what Help says, the ListIndex property can be set
when the combo box has the focus (like the Text property).

I seem to remember that this may also trigger the update
events, but I'm not sure. If it does, use a module level
flag variable to indicate that the AfterUpdate event should
immediately exit without doing its usual processing.
 
Marshall Barton said:
Inspite of what Help says, the ListIndex property can be set
when the combo box has the focus (like the Text property).

Well well well, isn't that interesting. I don't know why I pay
attention to documentation. It seems I'd have a much easier time of it
just doing whatever suits me.

So all that needs be done to navigate a combo/list box is to _set_ the
..ListIndex? So much for that fancy logic I came up with earlier today.
:)

I seem to remember that this may also trigger the update
events, but I'm not sure. If it does, use a module level
flag variable to indicate that the AfterUpdate event should
immediately exit without doing its usual processing.

Yeah.. I was thinking of such a flag, but then I have to figure out what
says it gets set one way or the other. Was hoping to avoid that.

Thanks again!
spark
 
**********************************************************
Dumb Question:

Have you tried turning off the warnings?
DoCmd.SetWarnings False
Insert String into new table with autoID
DoCmd.SetWarnings True

**********************************************************
 
**********************************************************
Another Possibility:
Time/Date Stamp the inserted records and use the max
function to get the highest date.
**********************************************************
 
Back
Top