Different types of Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry for what might be thought of as a silly question. I have a Combo that I
use as a "Find" Field. I also have a "Bound Text Box" to display the
information. Bacause I might want to edit the information that my "Find
Combo" has recovered, I also have an "Unbound Text Box" to handle any editing
that I may wish to do. All these three Boxes are superimposed on each other
and I use a combination of "Visible = True / False! to view and work with the
Box of choice.

Is this usual or is there a better way to do this?

Thanks RayC
 
There are several problems that can arise doing that. How you structure it
depends on what you are doing.
Usually, an unbound combo is used for finding a record in the form's
recordset and making it the current record.
If you want to limit the possible values that may be entered in a field,
then a bound combo box would be appropriate. Whether you want to allow the
user to enter values not in the combo's list is up to you. You can control
that by using the combo's Limit To List property.
You would use a bound text box if you want to allow more of a "free form"
entry in the field. You can limit and edit what is entered.
An unbound text box is usually used as a calculated control. That is, if
you want to display information to the user that you don't store in your
table. For example, you want to display the Employee's age, but because it
is a calculated value, it is improper to store it in a table. You store the
employee's birthdate in a field and use an unbound field to show the age.
You do that with an expression or a function in the text box Control Source
property.
 
Thanks for the input, I guess that I should be using a Combo as my "Find" box
and a Bound Text Box as my "Display / Edit! Box. I have tried that and it
seems to work but I am having all sorts of trouble geting the "Find" combo to
list the new info.
e.g.My "Find" combo lists the content of a Table and I select "123". I want
to change the content to "321" so I press a seperate "Edit" Buton which Finds
the data, hides the "Find" combo and shows the "Bound Text Box" that is
displaying "123. I type in "321" to the Bound Text Box and switch back to the
"Find" combo which is still displaying "123" as part of its drop doen list./
I have tried various combinations of "ReQuery" but I seem to run into all
kinds if dificulties.
Should I be doing something else to get the "Find" combo uodated?

Thanks RayC
 
You are using a technique that I would support.
I don't usually bother to keep a search combo in sync. You can use the
After Update event of the bound text box to change the value in the combo:

Me.cboSearch = Me.txtBoundBox

Also, you may want to also put the code in the Form Current event.
 
You need to requery the combobox, but after the new value is saved. So you
can force a save in the code and then requery the combobox or requery the
combobox using the on current event of the form or the after update event of
the form.

Or get fancy and set variable to True in the Before update event if the
edit/ change the value and then the after update event can check the value
of the variable and run the requery and reset the variable. Something like
the code below

Option Compare Database
Option Explicit
Dim tfFieldUpDated as Boolean

Private Sub Form_AfterUpdate()
If tfFieldUpdated = True Then
Me.cboxField.Requery
tfFieldUpdated = False
End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
tfFieldUpdated = Me.fID.OldValue & "" <> Me.fID.Value & ""
End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Doh!
--
Dave Hargis, Microsoft Access MVP


John Spencer said:
You need to requery the combobox, but after the new value is saved. So you
can force a save in the code and then requery the combobox or requery the
combobox using the on current event of the form or the after update event of
the form.

Or get fancy and set variable to True in the Before update event if the
edit/ change the value and then the after update event can check the value
of the variable and run the requery and reset the variable. Something like
the code below

Option Compare Database
Option Explicit
Dim tfFieldUpDated as Boolean

Private Sub Form_AfterUpdate()
If tfFieldUpdated = True Then
Me.cboxField.Requery
tfFieldUpdated = False
End If

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
tfFieldUpdated = Me.fID.OldValue & "" <> Me.fID.Value & ""
End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top